@@ 616-633 (lines=18) @@ | ||
613 | * @return array |
|
614 | * @throws \Sokil\Mongo\Exception |
|
615 | */ |
|
616 | public static function convertToArray($mixed) |
|
617 | { |
|
618 | // get expression from callable |
|
619 | if(is_callable($mixed)) { |
|
620 | $callable = $mixed; |
|
621 | $mixed = new self(); |
|
622 | call_user_func($callable, $mixed); |
|
623 | } |
|
624 | ||
625 | // get expression array |
|
626 | if($mixed instanceof Arrayable && $mixed instanceof self) { |
|
627 | $mixed = $mixed->toArray(); |
|
628 | } elseif(!is_array($mixed)) { |
|
629 | throw new Exception('Mixed must be instance of Expression'); |
|
630 | } |
|
631 | ||
632 | return $mixed; |
|
633 | } |
|
634 | } |
|
635 |
@@ 393-410 (lines=18) @@ | ||
390 | * @return array |
|
391 | * @throws \Sokil\Mongo\Exception |
|
392 | */ |
|
393 | public static function convertToArray($mixed) |
|
394 | { |
|
395 | // get operator from callable |
|
396 | if(is_callable($mixed)) { |
|
397 | $callable = $mixed; |
|
398 | $mixed = new self(); |
|
399 | call_user_func($callable, $mixed); |
|
400 | } |
|
401 | ||
402 | // get operator array |
|
403 | if($mixed instanceof Arrayable && $mixed instanceof self) { |
|
404 | $mixed = $mixed->toArray(); |
|
405 | } elseif(!is_array($mixed)) { |
|
406 | throw new Exception('Mixed must be instance of Operator'); |
|
407 | } |
|
408 | ||
409 | return $mixed; |
|
410 | } |
|
411 | } |
|
412 |