示例#1
0
 public function setUpFixtures()
 {
     // overload this
     if (\Psc\Code\Code::isTraversable($this->fixtures)) {
         foreach ($this->fixtures as $fixture) {
             $this->dcFixtures->add($fixture);
         }
     }
 }
示例#2
0
 /**
  * Organisiert die Collection mit einem neuen Index
  *
  * macht eine Kopie der $collection, deshalb erstmal nur array erlaubt, bis ich weiß, was da die arraycollection macht
  * @param string|Closure $getIndex wenn ein Closure wird als erster Parameter das Objekt der Collection übergeben. wenn ein string ist dies der Name des Getters des indexes für das Objekt in $collection
  * @TODO was ist schneller:
  *  1. $getIndex in ein Closure zu casten und dann einfach durchlaufe,
  *  2. oder $getIndex als String zu benutzen und jedes mal in der Schleife abfragen ob $getIndex ein String oder ein Closure ist
  *
  * @return array
  */
 public static function reindex($collection, $getIndex = 'getIdentifier')
 {
     if (!Code::isTraversable($collection)) {
         throw new \InvalidArgumentException('$collection muss Traversable sein. ' . Code::varInfo($collection));
     }
     $getIndex = Code::castGetter($getIndex);
     $ret = array();
     foreach ($collection as $o) {
         $ret[$getIndex($o)] = $o;
     }
     return $ret;
 }
示例#3
0
 public function __construct($arguments)
 {
     if ($arguments instanceof ArrayCollection) {
         // trust the dj
         $this->arguments = $arguments;
     } else {
         if (!Code::isTraversable($arguments)) {
             throw new \InvalidArgumentException('$arguments muss traversable sein.');
         }
         $this->arguments = new ArrayCollection();
         foreach ($arguments as $argument) {
             $this->addArgument($argument);
         }
     }
 }
示例#4
0
 public function __construct($parameters)
 {
     if ($parameters instanceof ArrayCollection) {
         // trust the dj
         $this->parameters = $parameters;
     } else {
         if (!Code::isTraversable($parameters)) {
             throw new \InvalidArgumentException('$parameters muss traversable sein.');
         }
         $this->parameters = new ArrayCollection();
         foreach ($parameters as $parameter) {
             $this->addParameter($parameter);
         }
     }
 }
示例#5
0
 public function setUpFixtures()
 {
     if (Code::isTraversable($this->fixtures)) {
         foreach ($this->fixtures as $fixture) {
             $this->dcFixtures->add($fixture);
         }
     }
 }
示例#6
0
 public function testTraversableTrues()
 {
     $this->assertTrue(Code::isTraversable(array('blubb')));
     $this->assertTrue(Code::isTraversable((object) array('blubb')));
     $this->assertTrue(Code::isTraversable(new \Psc\Data\ArrayCollection(array('blubb'))));
 }