build() public method

Transform to array
public build ( ) : array | string
return array | string
Example #1
0
 /**
  * get Options transformed
  *
  * @return array
  */
 protected function getOptions()
 {
     $options = $this->options ? $this->options->toArray() : [];
     if ($this->topic && !$this->topic->hasOnlyOneTopic()) {
         $options = array_merge($options, $this->topic->build());
     }
     return $options;
 }
Example #2
0
 /**
  * @test
  */
 public function it_has_a_complex_topic_condition()
 {
     $target = ['condition' => "'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics) || ('TopicD' in topics && 'TopicE' in topics)"];
     $topics = new Topics();
     $topics->topic('TopicA')->andTopic(function ($condition) {
         $condition->topic('TopicB')->orTopic('TopicC');
     })->orTopic(function ($condition) {
         $condition->topic('TopicD')->andTopic('TopicE');
     });
     $this->assertEquals($target, $topics->build());
 }