<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Grid\Grid; class Column implements Buildable { protected $width = array(); protected $contents = array(); public function __construct($ohNZt, $gCaaD = 12) { if ($ohNZt instanceof \Closure) { call_user_func($ohNZt, $this); } else { $this->append($ohNZt); } if (is_null($gCaaD) || is_array($gCaaD) && count($gCaaD) === 0) { $this->width['md'] = 12; } elseif (is_numeric($gCaaD)) { $this->width['md'] = $gCaaD; } else { $this->width = $gCaaD; } } public function append($ohNZt) { $this->contents[] = $ohNZt; return $this; } public function row($ohNZt) { goto SHQPj; E3pf_: $V0u2z->build(); goto OkhsB; OkhsB: $NMwSd = ob_get_contents(); goto A5phI; dziT1: ob_start(); goto E3pf_; SHQPj: if (!$ohNZt instanceof \Closure) { $V0u2z = new Row($ohNZt); } else { $V0u2z = new Row(); call_user_func($ohNZt, $V0u2z); } goto dziT1; A5phI: ob_end_clean(); goto CMJws; CMJws: return $this->append($NMwSd); goto z7rjp; z7rjp: } public function build() { goto KKdpR; jHpbg: foreach ($this->contents as $ohNZt) { if ($ohNZt instanceof Renderable || $ohNZt instanceof Grid) { echo $ohNZt->render(); } else { echo (string) $ohNZt; } } goto h_fyj; KKdpR: $this->startColumn(); goto jHpbg; h_fyj: $this->endColumn(); goto HnWBP; HnWBP: } protected function startColumn() { $rXcrQ = collect($this->width)->map(function ($ib3B9, $GUcFO) { return $GUcFO ? "col-{$GUcFO}-{$ib3B9}" : "col-{$ib3B9}"; })->implode(' '); echo "<div class=\"{$rXcrQ}\">"; } protected function endColumn() { echo '</div>'; } }