Exemplo n.º 1
0
 /**
  * @param $type
  *
  * @return bool
  */
 protected function typedNodesExists($type)
 {
     return ArrayUtil::some(function ($node) use($type) {
         $exists = false;
         if ($node instanceof GroupNode) {
             $exists = $node->getType() === $type;
         } else {
             switch ($type) {
                 case GroupNode::TYPE_COMPUTED:
                     $exists = $node->isComputed();
                     break;
                 case GroupNode::TYPE_UNCOMPUTED:
                     $exists = !$node->isComputed();
             }
         }
         return $exists;
     }, $this->nodes);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider someProvider
  */
 public function testSome(callable $callback, array $array, $expectedResult)
 {
     $this->assertSame($expectedResult, ArrayUtil::some($callback, $array));
 }
Exemplo n.º 3
0
 /**
  * @return string
  */
 public function getType()
 {
     $mixed = ArrayUtil::some(function ($node) {
         if ($node instanceof GroupNode) {
             return $node->getType() === GroupNode::TYPE_MIXED;
         }
         return false;
     }, $this->nodes);
     if ($mixed) {
         return GroupNode::TYPE_MIXED;
     }
     $computed = ArrayUtil::some(function ($node) {
         if ($node instanceof GroupNode) {
             return $node->getType() === GroupNode::TYPE_COMPUTED;
         }
         return $node->isComputed();
     }, $this->nodes);
     $unComputed = ArrayUtil::some(function ($node) {
         if ($node instanceof GroupNode) {
             return $node->getType() === GroupNode::TYPE_UNCOMPUTED;
         }
         return !$node->isComputed();
     }, $this->nodes);
     if ($computed && $unComputed) {
         return static::TYPE_MIXED;
     }
     return $computed ? static::TYPE_COMPUTED : static::TYPE_UNCOMPUTED;
 }