11<?php 
22
3+ /** 
4+  * @copyright Copyright (C) Ibexa AS. All rights reserved. 
5+  * @license For full copyright and license information view LICENSE file distributed with this source code. 
6+  */ 
7+ 
38namespace  spec \Ibexa \GraphQL \InputMapper ;
49
10+ use  Ibexa \Contracts \Core \Repository \Values \Content \Query ;
511use  Ibexa \Contracts \Core \Repository \Values \Content \Query \Criterion \Subtree ;
612use  Ibexa \GraphQL \InputMapper \ContentCollectionFilterBuilder ;
713use  Ibexa \GraphQL \InputMapper \SearchQueryMapper ;
8- use  Ibexa \Contracts \Core \Repository \Values \Content \Query ;
914use  PhpSpec \ObjectBehavior ;
1015
1116class  SearchQueryMapperSpec extends  ObjectBehavior
1217{
13-     function  let (ContentCollectionFilterBuilder $ filterBuilder
18+     public   function  let (ContentCollectionFilterBuilder $ filterBuilder:  void 
1419    {
1520        $ this beConstructedWith ($ filterBuilder
1621
1722        $ filterBuilderbuildFilter ()->willReturn (new  Subtree ('/1/2/ ' ));
1823    }
1924
20-     function  it_is_initializable ()
25+     public   function  it_is_initializable ():  void 
2126    {
2227        $ this shouldHaveType (SearchQueryMapper::class);
2328    }
2429
25-     public  function  it_maps_ContentTypeIdentifier_to_a_ContentTypeIdentifier_criterion ()
30+     public  function  it_maps_ContentTypeIdentifier_to_a_ContentTypeIdentifier_criterion ():  void 
2631    {
2732        $ this mapInputToQuery (['ContentTypeIdentifier '  => ['article ' ]])->shouldFilterByContentType (['article ' ]);
2833    }
2934
30-     public  function  it_maps_Text_to_a_FullText_criterion ()
35+     public  function  it_maps_Text_to_a_FullText_criterion ():  void 
3136    {
3237        $ this 
3338            ->mapInputToQuery (['Text '  => 'graphql ' ])
3439            ->shouldFilterByFullText ('graphql ' );
3540    }
3641
37-     public  function  it_maps_Modified_before_to_a_created_lte_DateMetaData_criterion ()
42+     public  function  it_maps_Modified_before_to_a_created_lte_DateMetaData_criterion ():  void 
3843    {
3944        $ this 
4045            ->mapInputToQuery (['Modified '  => ['before '  => '1977/05/04 ' ]])
4146            ->shouldFilterByDateModified (Query \Criterion \Operator::LTE , '1977/05/04 ' );
4247    }
4348
44-     public  function  it_maps_Modified_on_to_a_created_eq_DateMetaData_criterion ()
49+     public  function  it_maps_Modified_on_to_a_created_eq_DateMetaData_criterion ():  void 
4550    {
4651        $ this 
4752            ->mapInputToQuery (['Modified '  => ['on '  => '1977/05/04 ' ]])
4853            ->shouldFilterByDateModified (Query \Criterion \Operator::EQ , '1977/05/04 ' );
4954    }
5055
51-     public  function  it_maps_Modified_after_to_a_created_gte_DateMetaData_criterion ()
56+     public  function  it_maps_Modified_after_to_a_created_gte_DateMetaData_criterion ():  void 
5257    {
5358        $ this 
5459            ->mapInputToQuery (['Modified '  => ['after '  => '1977/05/04 ' ]])
5560            ->shouldFilterByDateModified (Query \Criterion \Operator::GTE , '1977/05/04 ' );
5661    }
5762
58-     public  function  it_maps_Created_before_to_a_created_lte_DateMetaData_criterion ()
63+     public  function  it_maps_Created_before_to_a_created_lte_DateMetaData_criterion ():  void 
5964    {
6065        $ this 
6166            ->mapInputToQuery (['Created '  => ['before '  => '1977/05/04 ' ]])
6267            ->shouldFilterByDateCreated (Query \Criterion \Operator::LTE , '1977/05/04 ' );
6368    }
6469
65-     public  function  it_maps_Created_on_to_a_created_eq_DateMetaData_criterion ()
70+     public  function  it_maps_Created_on_to_a_created_eq_DateMetaData_criterion ():  void 
6671    {
6772        $ this 
6873            ->mapInputToQuery (['Created '  => ['on '  => '1977/05/04 ' ]])
6974            ->shouldFilterByDateCreated (Query \Criterion \Operator::EQ , '1977/05/04 ' );
7075    }
7176
72-     public  function  it_maps_Created_after_to_a_created_gte_DateMetaData_criterion ()
77+     public  function  it_maps_Created_after_to_a_created_gte_DateMetaData_criterion ():  void 
7378    {
7479        $ this 
7580            ->mapInputToQuery (['Created '  => ['after '  => '1977/05/04 ' ]])
7681            ->shouldFilterByDateCreated (Query \Criterion \Operator::GTE , '1977/05/04 ' );
7782    }
7883
79-     function  it_maps_Field_to_a_Field_criterion ()
84+     public   function  it_maps_Field_to_a_Field_criterion ():  void 
8085    {
8186        $ this 
8287            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'eq '  => 'bar ' ]])
8388            ->shouldFilterByField ('target_field ' );
8489    }
8590
86-     function  it_maps_Field_target_to_the_Field_criterion_target ()
91+     public   function  it_maps_Field_target_to_the_Field_criterion_target ():  void 
8792    {
8893        $ this 
8994            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'eq '  => 'bar ' ]])
9095            ->shouldFilterByField ('target_field ' , Query \Criterion \Operator::EQ , 'bar ' );
9196    }
9297
93-     function  it_maps_Field_with_value_at_operator_key_to_the_Field_criterion_value ()
98+     public   function  it_maps_Field_with_value_at_operator_key_to_the_Field_criterion_value ():  void 
9499    {
95100        $ this 
96101            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'eq '  => 'bar ' ]])
97102            ->shouldFilterByField ('target_field ' , null , 'bar ' );
98103    }
99104
100-     function  it_maps_Field_operator_eq_to_Field_criterion_operator_EQ ()
105+     public   function  it_maps_Field_operator_eq_to_Field_criterion_operator_EQ ():  void 
101106    {
102107        $ this 
103108            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'eq '  => 'bar ' ]])
104109            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::EQ );
105110    }
106111
107-     function  it_maps_Field_operator_in_to_Field_criterion_operator_IN ()
112+     public   function  it_maps_Field_operator_in_to_Field_criterion_operator_IN ():  void 
108113    {
109114        $ this 
110115            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'eq '  => 'bar ' ]])
111116            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::EQ );
112117    }
113118
114-     function  it_maps_Field_operator_lt_to_Field_criterion_operator_LT ()
119+     public   function  it_maps_Field_operator_lt_to_Field_criterion_operator_LT ():  void 
115120    {
116121        $ this 
117122            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'lt '  => 'bar ' ]])
118123            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::LT );
119124    }
120125
121-     function  it_maps_Field_operator_lte_to_Field_criterion_operator_LTE ()
126+     public   function  it_maps_Field_operator_lte_to_Field_criterion_operator_LTE ():  void 
122127    {
123128        $ this 
124129            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'lte '  => 'bar ' ]])
125130            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::LTE );
126131    }
127132
128-     function  it_maps_Field_operator_gte_to_Field_criterion_operator_GTE ()
133+     public   function  it_maps_Field_operator_gte_to_Field_criterion_operator_GTE ():  void 
129134    {
130135        $ this 
131136            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'gte '  => 'bar ' ]])
132137            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::GTE );
133138    }
134139
135-     function  it_maps_Field_operator_gt_to_Field_criterion_operator_GT ()
140+     public   function  it_maps_Field_operator_gt_to_Field_criterion_operator_GT ():  void 
136141    {
137142        $ this 
138143            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'gt '  => 'bar ' ]])
139144            ->shouldFilterByFieldWithOperator (Query \Criterion \Operator::GT );
140145    }
141146
142-     function  it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN ()
147+     public   function  it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN ():  void 
143148    {
144149        $ this 
145150            ->mapInputToQuery (['Field '  => ['target '  => 'target_field ' , 'between '  => [10 , 20 ]]])
@@ -149,7 +154,7 @@ function it_maps_Field_operator_between_to_Field_criterion_operator_BETWEEN()
149154    public  function  getMatchers (): array 
150155    {
151156        return  [
152-             'filterByContentType '  => function (Query $ queryarray  $ contentTypes
157+             'filterByContentType '  => function   (Query $ queryarray  $ contentTypes:  bool  {
153158                $ criterion$ this findCriterionInQueryFilter (
154159                    $ query
155160                    Query \Criterion \ContentTypeIdentifier::class
@@ -161,7 +166,7 @@ public function getMatchers(): array
161166
162167                return  $ criterionvalue  === $ contentTypes
163168            },
164-             'filterByFullText '  => function (Query $ query$ text
169+             'filterByFullText '  => function   (Query $ query$ text:  bool  {
165170                $ criterion$ this findCriterionInQueryFilter (
166171                    $ query
167172                    Query \Criterion \FullText::class
@@ -173,7 +178,7 @@ public function getMatchers(): array
173178
174179                return  $ criterionvalue  === $ text
175180            },
176-             'filterByDateModified '  => function (Query $ query$ operator$ date
181+             'filterByDateModified '  => function   (Query $ query$ operator$ date:  bool  {
177182                $ criterion$ this findCriterionInQueryFilter ($ queryQuery \Criterion \DateMetadata::class);
178183
179184                if  ($ criterionnull ) {
@@ -187,7 +192,7 @@ public function getMatchers(): array
187192                return  $ criterionoperator  == $ operator
188193                    && $ criterionvalue [0 ] == strtotime ($ date
189194            },
190-             'filterByDateCreated '  => function (Query $ query$ operator$ date
195+             'filterByDateCreated '  => function   (Query $ query$ operator$ date:  bool  {
191196                $ criterion$ this findCriterionInQueryFilter ($ queryQuery \Criterion \DateMetadata::class);
192197
193198                if  ($ criterionnull ) {
@@ -201,7 +206,7 @@ public function getMatchers(): array
201206                return  $ criterionoperator  == $ operator
202207                    && $ criterionvalue [0 ] == strtotime ($ date
203208            },
204-             'filterByField '  => function (Query $ query$ field$ operatornull , $ valuenull ) {
209+             'filterByField '  => function   (Query $ query$ field$ operatornull , $ valuenull ):  bool  {
205210                $ criterion$ this findCriterionInQueryFilter ($ queryQuery \Criterion \Field::class);
206211
207212                if  ($ criterionnull ) {
@@ -215,20 +220,21 @@ public function getMatchers(): array
215220                if  ($ operatornull  && $ criterionoperator  != $ operator
216221                    return  false ;
217222                }
218-                 return  ($ valuenull  || $ criterionvalue  == $ value
223+ 
224+                 return  $ valuenull  || $ criterionvalue  == $ value
219225            },
220-             'filterByFieldWithOperator '  => function (Query $ query$ operator
226+             'filterByFieldWithOperator '  => function   (Query $ query$ operator:  bool  {
221227                $ criterion$ this findCriterionInQueryFilter ($ queryQuery \Criterion \Field::class);
222228                if  ($ criterionnull ) {
223229                    return  false ;
224230                }
225231
226232                return  $ criterionoperator  == $ operator
227-             }
233+             }, 
228234        ];
229235    }
230236
231-     private  function  findCriterionInQueryFilter (Query $ query$ searchedCriterionClass
237+     private  function  findCriterionInQueryFilter (Query $ querystring   $ searchedCriterionClass
232238    {
233239        if  ($ queryfilter  instanceof  Query \Criterion \LogicalOperator) {
234240            return  $ this findCriterionInCriterion ($ queryfilter , $ searchedCriterionClass
0 commit comments