@@ 61-88 (lines=28) @@ | ||
58 | * |
|
59 | * @return array |
|
60 | */ |
|
61 | public function toArray(array $options=[]) |
|
62 | { |
|
63 | $default_options = [ |
|
64 | 'show_instance' => false, |
|
65 | ]; |
|
66 | foreach ($default_options as $default_option => &$default_value) { |
|
67 | if ( ! isset($options[ $default_option ])) { |
|
68 | $options[ $default_option ] = $default_value; |
|
69 | } |
|
70 | } |
|
71 | ||
72 | if ( ! $options['show_instance'] && isset($this->cache['array'])) { |
|
73 | return $this->cache['array']; |
|
74 | } |
|
75 | ||
76 | $array = [ |
|
77 | $this->getField(), |
|
78 | $options['show_instance'] ? $this->getInstanceId() : self::operator, |
|
79 | $this->getValue(), |
|
80 | ]; |
|
81 | ||
82 | if ( ! $options['show_instance']) { |
|
83 | return $this->cache['array'] = $array; |
|
84 | } |
|
85 | else { |
|
86 | return $array; |
|
87 | } |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | */ |
@@ 174-203 (lines=30) @@ | ||
171 | * |
|
172 | * @return array |
|
173 | */ |
|
174 | public function toArray(array $options=[]) |
|
175 | { |
|
176 | $default_options = [ |
|
177 | 'show_instance' => false, |
|
178 | ]; |
|
179 | foreach ($default_options as $default_option => &$default_value) { |
|
180 | if ( ! isset($options[ $default_option ])) { |
|
181 | $options[ $default_option ] = $default_value; |
|
182 | } |
|
183 | } |
|
184 | ||
185 | $class = get_class($this); |
|
186 | ||
187 | if ( ! $options['show_instance'] && isset($this->cache['array'])) { |
|
188 | return $this->cache['array']; |
|
189 | } |
|
190 | ||
191 | $array = [ |
|
192 | $this->getField(), |
|
193 | $options['show_instance'] ? $this->getInstanceId() : $class::operator, |
|
194 | $this->getValues(), |
|
195 | ]; |
|
196 | ||
197 | if ( ! $options['show_instance']) { |
|
198 | return $this->cache['array'] = $array; |
|
199 | } |
|
200 | else { |
|
201 | return $array; |
|
202 | } |
|
203 | } |
|
204 | ||
205 | /** |
|
206 | */ |