Пример #1
0
 public function testGetSet()
 {
     $items = new ObjectCollection();
     $this->assertNull($items->get('test'));
     $items->set('test', 'call me maybe?');
     $this->assertEquals('call me maybe?', $items->get('test'));
 }
Пример #2
0
 /**
  * Build objects using the build definition
  * @param string $name The identifier of the build definition
  * @param int $quantity (optional) The number of objects to build, defaults to 1 only. If the quantity specified is more than 1, an array of objects will be returned instead of just the object.
  * @return mixed|array Returns the resulting object. If the quantity is more than one, an array of the objects is returned instead.
  * @since 1.0.0
  */
 public function build($name, $quantity = 1)
 {
     if ($definition = $this->objects->get($name)) {
         $result = array();
         for ($i = 0; $i < $quantity; ++$i) {
             $result[] = $definition->build();
         }
         if ($quantity == 1) {
             $result = $result[0];
         }
         return $result;
     }
     throw new \Exception('Tried to build undefined Samsui definition "' . $name . '".');
 }