@@ 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 |
@@ 678-695 (lines=18) @@ | ||
675 | * @return array |
|
676 | * @throws \Sokil\Mongo\Exception |
|
677 | */ |
|
678 | public static function convertToArray($mixed) |
|
679 | { |
|
680 | // get expression from callable |
|
681 | if(is_callable($mixed)) { |
|
682 | $callable = $mixed; |
|
683 | $mixed = new self(); |
|
684 | call_user_func($callable, $mixed); |
|
685 | } |
|
686 | ||
687 | // get expression array |
|
688 | if($mixed instanceof Arrayable && $mixed instanceof self) { |
|
689 | $mixed = $mixed->toArray(); |
|
690 | } elseif(!is_array($mixed)) { |
|
691 | throw new Exception('Mixed must be instance of Expression'); |
|
692 | } |
|
693 | ||
694 | return $mixed; |
|
695 | } |
|
696 | } |
|
697 |