/** * Adds the given classes to attributes * * @param array $classes * @return $this * @static */ public static function addClass($classes) { //Method inherited from \Bootstrapper\RenderedObject return \Bootstrapper\Table::addClass($classes); }
public function testWeCanOnlyGetCertainThingsWithAnArray() { $body = Table::body($this->body)->only(array('foo', 'kal'))->render(); $matcher = '<tbody><tr><td class="column-foo">foo</td><td class="column-kal">kal</td></tr></tbody>'; $this->assertEquals($matcher, $body); }
public function testAlwaysIgnoreOverridesManuallyIgnore() { Config::set('table.ignore', array('foo')); $body = Table::body($this->body)->ignore('bar')->__toString(); $matcher = '<tbody><tr><td class="column-foo">foo</td><td class="column-kal">kal</td></tr></tbody>'; $this->assertEquals($matcher, $body); }
function it_should_throw_when_the_table_object_throws(Table $table) { $table->render()->willThrow('ErrorException'); $this->withTable($table)->shouldThrow('ErrorException')->during('render'); }
/** * Checks call to see if we can create a table from a magic call (for you wizards). * hover_striped, bordered_condensed, etc. * * @param string $method Method name * @param array $parameters Method parameters * * @return mixed */ public static function __callStatic($method, $parameters) { // Opening a table if (str_contains($method, 'open') or $method == 'open') { $method = strtolower($method); $classes = explode('_', $method); $method = array_pop($classes); // Fallback to default type if defined if (sizeof($classes) == 0) { $classes = Config::get('table.classes'); } // Filter table classes $classes = array_intersect($classes, static::$classes); $attributes = Helpers::set_multi_class_attributes($method, $classes, $parameters, 0, 'table-'); $attributes = array_get($attributes, 0); static::$table = new static($attributes); return static::$table->open(); } // Set default function if (!$method) { $method = 'table'; } // Use cases switch ($method) { case 'close': $close = static::table()->close(); static::$table = null; return $close; break; default: return call_user_func_array(array(static::table(), $method), $parameters); break; } }