Esempio n. 1
0
 /**
  * Construct table
  *
  * @param   array|Traversable $source
  * @param   array|Traversable $fields
  */
 public function __construct($source, $fields)
 {
     if (is_array($source)) {
         $source = new ArrayIterator($source);
     }
     while ($source instanceof IteratorAggregate) {
         $source = $source->getIterator();
     }
     if (!$source instanceof Iterator) {
         throw new Exception\InvalidArgumentException(sprintf('%s: $source must be an array, or an instance of \\Traversable', __METHOD__));
     }
     $this->iterator = $source;
     foreach ($fields as $name => $type) {
         $this->fields[$name] = Transform::toCallable($type);
     }
 }
Esempio n. 2
0
 /**
  * Test transform on not callable
  *
  * @expectedException   InvalidArgumentException
  */
 public function testNotCallable()
 {
     Transform::toCallable('function_that_not_exists');
 }