<?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($DTnPC, $r3IZu = 12) { if ($DTnPC instanceof \Closure) { call_user_func($DTnPC, $this); } else { $this->append($DTnPC); } if (is_null($r3IZu) || is_array($r3IZu) && count($r3IZu) === 0) { $this->width['md'] = 12; } elseif (is_numeric($r3IZu)) { $this->width['md'] = $r3IZu; } else { $this->width = $r3IZu; } } public function append($DTnPC) { $this->contents[] = $DTnPC; return $this; } public function row($DTnPC) { goto fJCJ5; ptrGB: ob_end_clean(); goto KqgW2; xMjY2: $Ah4uW->build(); goto ofpA0; KqgW2: return $this->append($wvdXH); goto xnaqB; fJCJ5: if (!$DTnPC instanceof \Closure) { $Ah4uW = new Row($DTnPC); } else { $Ah4uW = new Row(); call_user_func($DTnPC, $Ah4uW); } goto ioWYC; ioWYC: ob_start(); goto xMjY2; ofpA0: $wvdXH = ob_get_contents(); goto ptrGB; xnaqB: } public function build() { goto v13fD; Q8DEx: foreach ($this->contents as $DTnPC) { if ($DTnPC instanceof Renderable || $DTnPC instanceof Grid) { echo $DTnPC->render(); } else { echo (string) $DTnPC; } } goto WxF6f; v13fD: $this->startColumn(); goto Q8DEx; WxF6f: $this->endColumn(); goto AgkVt; AgkVt: } protected function startColumn() { $Bkn_0 = collect($this->width)->map(function ($gwXrh, $rvTrU) { return $rvTrU ? "col-{$rvTrU}-{$gwXrh}" : "col-{$gwXrh}"; })->implode(' '); echo "<div class=\"{$Bkn_0}\">"; } protected function endColumn() { echo '</div>'; } }