Ejemplo n.º 1
0
 protected function getGroups($count, $chars = '&|!')
 {
     $groups = [];
     for ($i = 0; $i < $count; $i++) {
         $groups[] = GroupFactory::build(substr(str_shuffle($chars), 0, 1), substr(str_shuffle($chars), 0, 1));
     }
     return $groups;
 }
Ejemplo n.º 2
0
 public function testResult()
 {
     $this->assertInstanceOf(Group::class, GroupFactory::build('&'));
 }
Ejemplo n.º 3
0
 /**
  * Solve the group context. 
  * 
  * @param string $logical
  * @param bool   $negation
  * 
  * @return Builder
  */
 protected function solveContext($logical, $negation)
 {
     if ($this->group->getOperator() !== $logical) {
         // If the current group operator is different from the requested
         // spawn a new group and nest the current one
         $group = GroupFactory::build($logical);
         $this->group->nest($group);
         $this->group = $group;
     }
     if ($negation) {
         // Create a new ! group, push it without clone and return to
         // build query on it.
         $context = GroupFactory::build('!');
         $group = GroupFactory::build();
         $context->push($group, false);
         $this->group->push($context, false);
         return $group;
     }
     return $this->group;
 }