<?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($cgjRu, $aI0SX = 12) { if ($cgjRu instanceof \Closure) { call_user_func($cgjRu, $this); } else { $this->append($cgjRu); } if (is_null($aI0SX) || is_array($aI0SX) && count($aI0SX) === 0) { $this->width['md'] = 12; } elseif (is_numeric($aI0SX)) { $this->width['md'] = $aI0SX; } else { $this->width = $aI0SX; } } public function append($cgjRu) { $this->contents[] = $cgjRu; return $this; } public function row($cgjRu) { goto Ft3ZI; yjvCE: ob_end_clean(); goto ScRnb; dI59z: $Bhp8r->build(); goto ZN6BO; ZN6BO: $R428K = ob_get_contents(); goto yjvCE; Ft3ZI: if (!$cgjRu instanceof \Closure) { $Bhp8r = new Row($cgjRu); } else { $Bhp8r = new Row(); call_user_func($cgjRu, $Bhp8r); } goto R2Ig6; ScRnb: return $this->append($R428K); goto cgBRb; R2Ig6: ob_start(); goto dI59z; cgBRb: } public function build() { goto Y3XsB; Y3XsB: $this->startColumn(); goto xHFrK; yBSDo: $this->endColumn(); goto k0SrQ; xHFrK: foreach ($this->contents as $cgjRu) { if ($cgjRu instanceof Renderable || $cgjRu instanceof Grid) { echo $cgjRu->render(); } else { echo (string) $cgjRu; } } goto yBSDo; k0SrQ: } protected function startColumn() { $vtWM8 = collect($this->width)->map(function ($wvO30, $dwwIV) { return $dwwIV ? "col-{$dwwIV}-{$wvO30}" : "col-{$wvO30}"; })->implode(' '); echo "<div class=\"{$vtWM8}\">"; } protected function endColumn() { echo '</div>'; } }