Ejemplo n.º 1
0
 /**
  * @dataProvider  flattenProvider
  */
 public function testFlatten($input, $expected)
 {
     $this->assertSame($expected, Arrays::flatten($input));
 }
Ejemplo n.º 2
0
 /**
  * Adds one or more content items to this template.
  * You may add content in the following ways:
  *   $c->setContent($content);
  *   $c->setContent($content0, $content1, ...);
  *   $c->setContent(array($content0, $content1, ...));
  *
  * @param  mixed  ...  The content item(s) to add.
  *
  * @return  Chrome  The current object, for method chaining.
  *
  * @throws  \InvalidArgumentException
  */
 public function setContent()
 {
     if (func_num_args() < 1) {
         throw new \InvalidArgumentException('You must specify a content item.');
     }
     $items = Arrays::flatten(func_get_args());
     foreach ($items as $i) {
         if (!$i instanceof Renderable && !is_string($i) && !(is_object($i) && method_exists($i, '__toString'))) {
             throw new \InvalidArgumentException('Non-renderable or non-string item set as content.');
         }
     }
     $this->content = $items;
     $this->contentIterator = null;
     return $this;
 }