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;
 }
 public function testResult()
 {
     $this->assertInstanceOf(Group::class, GroupFactory::build('&'));
 }
Exemple #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;
 }