Conditions | 7 |
Paths | 7 |
Total Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 0 |
1 | <?php |
||
23 | protected function foreign_to_json( $foreign ) { |
||
24 | if ( empty( $foreign ) ) { |
||
25 | return array( |
||
26 | 'relation' => 'AND', |
||
27 | 'conditions' => array(), |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | if ( ! isset( $foreign['relation'] ) ) { |
||
32 | return $foreign; |
||
33 | } |
||
34 | |||
35 | $conditions = array(); |
||
36 | |||
37 | foreach ( $foreign as $key => $value ) { |
||
38 | if ( $key === 'relation' ) { |
||
39 | continue; |
||
40 | } |
||
41 | |||
42 | if ( isset( $value['relation'] ) ) { |
||
43 | $conditions[] = $this->foreign_to_json( $value ); |
||
44 | } else { |
||
45 | if ( isset( $value['type'] ) ) { |
||
46 | $conditions[] = $value; |
||
47 | } else { |
||
48 | $conditions = array_merge( $conditions, $value ); |
||
49 | } |
||
50 | } |
||
51 | } |
||
52 | |||
53 | return array( |
||
54 | 'relation' => $foreign['relation'], |
||
55 | 'conditions' => $conditions, |
||
56 | ); |
||
57 | } |
||
58 | } |
||
59 |