|
27 | 27 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\BooleanType;
|
28 | 28 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\DateTimeType;
|
29 | 29 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\DateType;
|
| 30 | +use WikibaseSolutions\CypherDSL\Types\PropertyTypes\LocalDateTimeType; |
| 31 | +use WikibaseSolutions\CypherDSL\Types\PropertyTypes\LocalTimeType; |
30 | 32 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\NumeralType;
|
31 | 33 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\PointType;
|
32 | 34 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\PropertyType;
|
33 | 35 | use WikibaseSolutions\CypherDSL\Types\PropertyTypes\StringType;
|
| 36 | +use WikibaseSolutions\CypherDSL\Types\PropertyTypes\TimeType; |
34 | 37 |
|
35 | 38 | /**
|
36 | 39 | * Helper class to construct literals.
|
@@ -494,6 +497,370 @@ public static function datetimeString($dateString): DateTimeType {
|
494 | 497 | return FunctionCall::datetime($dateString);
|
495 | 498 | }
|
496 | 499 |
|
| 500 | + /** |
| 501 | + * Creates the current localDateTime value |
| 502 | + * |
| 503 | + * @param null|string|StringType $timezone |
| 504 | + * @return LocalDateTimeType |
| 505 | + * |
| 506 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-current |
| 507 | + */ |
| 508 | + public static function localDatetime($timezone = null): LocalDateTimeType { |
| 509 | + if ($timezone === null) { |
| 510 | + return FunctionCall::localdatetime(); |
| 511 | + } |
| 512 | + |
| 513 | + if (!($timezone instanceof StringType)) { |
| 514 | + $timezone = self::string($timezone); |
| 515 | + } |
| 516 | + return FunctionCall::localdatetime(Query::map(["timezone" => $timezone])); |
| 517 | + } |
| 518 | + |
| 519 | + /** |
| 520 | + * Creates a LocalDateTime value with specified year, month, day and time props |
| 521 | + * |
| 522 | + * @param int|NumeralType $year |
| 523 | + * @param null|int|NumeralType $month |
| 524 | + * @param null|int|NumeralType $day |
| 525 | + * @param null|int|NumeralType $hour |
| 526 | + * @param null|int|NumeralType $minute |
| 527 | + * @param null|int|NumeralType $second |
| 528 | + * @param null|int|NumeralType $millisecond |
| 529 | + * @param null|int|NumeralType $microsecond |
| 530 | + * @param null|int|NumeralType $nanosecond |
| 531 | + * @return LocalDateTimeType |
| 532 | + * |
| 533 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-calendar |
| 534 | + */ |
| 535 | + public static function localDatetimeYMD($year, $month = null, $day = null, $hour = null, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null): LocalDateTimeType { |
| 536 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 537 | + "month" => $month, |
| 538 | + "day" => $day, |
| 539 | + "hour" => $hour, |
| 540 | + "minute" => $minute, |
| 541 | + "second" => $second, |
| 542 | + "millisecond" => $millisecond, |
| 543 | + "microsecond" => $microsecond, |
| 544 | + "nanosecond" => $nanosecond |
| 545 | + ]); |
| 546 | + |
| 547 | + if (!($year instanceof NumeralType)) { |
| 548 | + $year = self::decimal($year); |
| 549 | + } |
| 550 | + |
| 551 | + $map = ["year" => $year]; |
| 552 | + |
| 553 | + if ($month !== null) $map["month"] = $setVariables["month"]; |
| 554 | + if ($day !== null) $map["day"] = $setVariables["day"]; |
| 555 | + if ($hour !== null) $map["hour"] = $setVariables["hour"]; |
| 556 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 557 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 558 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 559 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 560 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 561 | + |
| 562 | + return FunctionCall::localdatetime(Query::map($map)); |
| 563 | + } |
| 564 | + |
| 565 | + /** |
| 566 | + * Creates a LocalDateTime value with the specified year, week, dayOfWeek, hour, minute, |
| 567 | + * second, millisecond, microsecond and nanosecond component value |
| 568 | + * |
| 569 | + * @param int|NumeralType $year |
| 570 | + * @param null|int|NumeralType $week |
| 571 | + * @param null|int|NumeralType $dayOfWeek |
| 572 | + * @param null|int|NumeralType $hour |
| 573 | + * @param null|int|NumeralType $minute |
| 574 | + * @param null|int|NumeralType $second |
| 575 | + * @param null|int|NumeralType $millisecond |
| 576 | + * @param null|int|NumeralType $microsecond |
| 577 | + * @param null|int|NumeralType $nanosecond |
| 578 | + * @return LocalDateTimeType |
| 579 | + * |
| 580 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-week |
| 581 | + */ |
| 582 | + public static function localDatetimeYWD($year, $week = null, $dayOfWeek = null, $hour = null, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null): LocalDateTimeType { |
| 583 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 584 | + "week" => $week, |
| 585 | + "dayOfWeek" => $dayOfWeek, |
| 586 | + "hour" => $hour, |
| 587 | + "minute" => $minute, |
| 588 | + "second" => $second, |
| 589 | + "millisecond" => $millisecond, |
| 590 | + "microsecond" => $microsecond, |
| 591 | + "nanosecond" => $nanosecond |
| 592 | + ]); |
| 593 | + |
| 594 | + if (!($year instanceof NumeralType)) { |
| 595 | + $year = self::decimal($year); |
| 596 | + } |
| 597 | + |
| 598 | + $map = ["year" => $year]; |
| 599 | + |
| 600 | + if ($week !== null) $map["week"] = $setVariables["week"]; |
| 601 | + if ($dayOfWeek !== null) $map["dayOfWeek"] = $setVariables["dayOfWeek"]; |
| 602 | + if ($hour !== null) $map["hour"] = $setVariables["hour"]; |
| 603 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 604 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 605 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 606 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 607 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 608 | + |
| 609 | + return FunctionCall::localdatetime(Query::map($map)); |
| 610 | + } |
| 611 | + |
| 612 | + /** |
| 613 | + * Creates a LocalDateTime value with the specified year, quarter, dayOfQuarter, hour, minute, second, millisecond, microsecond and nanosecond component values |
| 614 | + * |
| 615 | + * @param $year |
| 616 | + * @param null $quarter |
| 617 | + * @param null $dayOfQuarter |
| 618 | + * @param null $hour |
| 619 | + * @param null $minute |
| 620 | + * @param null $second |
| 621 | + * @param null $millisecond |
| 622 | + * @param null $microsecond |
| 623 | + * @param null $nanosecond |
| 624 | + * @return LocalDateTimeType |
| 625 | + * |
| 626 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-quarter |
| 627 | + */ |
| 628 | + public static function localDatetimeYQD($year, $quarter = null, $dayOfQuarter = null, $hour = null, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null): LocalDateTimeType { |
| 629 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 630 | + "quarter" => $quarter, |
| 631 | + "dayOfQuarter" => $dayOfQuarter, |
| 632 | + "hour" => $hour, |
| 633 | + "minute" => $minute, |
| 634 | + "second" => $second, |
| 635 | + "millisecond" => $millisecond, |
| 636 | + "microsecond" => $microsecond, |
| 637 | + "nanosecond" => $nanosecond |
| 638 | + ]); |
| 639 | + |
| 640 | + if (!($year instanceof NumeralType)) { |
| 641 | + $year = self::decimal($year); |
| 642 | + } |
| 643 | + |
| 644 | + $map = ["year" => $year]; |
| 645 | + |
| 646 | + if ($quarter !== null) $map["quarter"] = $setVariables["quarter"]; |
| 647 | + if ($dayOfQuarter !== null) $map["dayOfQuarter"] = $setVariables["dayOfQuarter"]; |
| 648 | + if ($hour !== null) $map["hour"] = $setVariables["hour"]; |
| 649 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 650 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 651 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 652 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 653 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 654 | + |
| 655 | + return FunctionCall::localdatetime(Query::map($map)); |
| 656 | + } |
| 657 | + |
| 658 | + /** |
| 659 | + * Creates a LocalDateTime value with the specified year, ordinalDay, hour, minute, second, millisecond, microsecond and nanosecond component values |
| 660 | + * |
| 661 | + * @param int|NumeralType $year |
| 662 | + * @param null|int|NumeralType $ordinalDay |
| 663 | + * @param null|int|NumeralType $hour |
| 664 | + * @param null|int|NumeralType $minute |
| 665 | + * @param null|int|NumeralType $second |
| 666 | + * @param null|int|NumeralType $millisecond |
| 667 | + * @param null|int|NumeralType $microsecond |
| 668 | + * @param null|int|NumeralType $nanosecond |
| 669 | + * @return LocalDateTimeType |
| 670 | + * |
| 671 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-ordinal |
| 672 | + */ |
| 673 | + public static function localDatetimeYD($year, $ordinalDay = null, $hour = null, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null): LocalDateTimeType { |
| 674 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 675 | + "ordinalDay" => $ordinalDay, |
| 676 | + "hour" => $hour, |
| 677 | + "minute" => $minute, |
| 678 | + "second" => $second, |
| 679 | + "millisecond" => $millisecond, |
| 680 | + "microsecond" => $microsecond, |
| 681 | + "nanosecond" => $nanosecond |
| 682 | + ]); |
| 683 | + |
| 684 | + if (!($year instanceof NumeralType)) { |
| 685 | + $year = self::decimal($year); |
| 686 | + } |
| 687 | + |
| 688 | + $map = ["year" => $year]; |
| 689 | + |
| 690 | + if ($ordinalDay !== null) $map["ordinalDay"] = $setVariables["ordinalDay"]; |
| 691 | + if ($hour !== null) $map["hour"] = $setVariables["hour"]; |
| 692 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 693 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 694 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 695 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 696 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 697 | + |
| 698 | + return FunctionCall::localdatetime(Query::map($map)); |
| 699 | + } |
| 700 | + |
| 701 | + /** |
| 702 | + * Creates the LocalDateTime value obtained by parsing a string representation of a temporal value |
| 703 | + * |
| 704 | + * @param string|StringType $localDateTimeString |
| 705 | + * @return LocalDateTimeType |
| 706 | + * |
| 707 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localdatetime-create-string |
| 708 | + */ |
| 709 | + public static function localDatetimeString($localDateTimeString): LocalDateTimeType { |
| 710 | + if (!($localDateTimeString instanceof StringType)) { |
| 711 | + $localDateTimeString = self::string($localDateTimeString); |
| 712 | + } |
| 713 | + |
| 714 | + return FunctionCall::localdatetime($localDateTimeString); |
| 715 | + } |
| 716 | + |
| 717 | + /** |
| 718 | + * Creates the current LocalTime value |
| 719 | + * |
| 720 | + * @param null|string|StringType $timezone |
| 721 | + * @return LocalTimeType |
| 722 | + * |
| 723 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localtime-current |
| 724 | + */ |
| 725 | + public static function localTimeCurrent($timezone = null): LocalTimeType { |
| 726 | + if ($timezone === null) { |
| 727 | + return FunctionCall::localtime(); |
| 728 | + } |
| 729 | + |
| 730 | + if (!($timezone instanceof StringType)) { |
| 731 | + $timezone = self::string($timezone); |
| 732 | + } |
| 733 | + return FunctionCall::localtime(Query::map(["timezone" => $timezone])); |
| 734 | + } |
| 735 | + |
| 736 | + /** |
| 737 | + * Creates a LocalTime value with the specified hour, minute, second, millisecond, microsecond and nanosecond component values |
| 738 | + * |
| 739 | + * @param int|NumeralType $hour |
| 740 | + * @param null|int|NumeralType $minute |
| 741 | + * @param null|int|NumeralType $second |
| 742 | + * @param null|int|NumeralType $millisecond |
| 743 | + * @param null|int|NumeralType $microsecond |
| 744 | + * @param null|int|NumeralType $nanosecond |
| 745 | + * @return LocalTimeType |
| 746 | + * |
| 747 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-localtime-create |
| 748 | + */ |
| 749 | + public static function localTime($hour, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null): LocalTimeType { |
| 750 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 751 | + "minute" => $minute, |
| 752 | + "second" => $second, |
| 753 | + "millisecond" => $millisecond, |
| 754 | + "microsecond" => $microsecond, |
| 755 | + "nanosecond" => $nanosecond |
| 756 | + ]); |
| 757 | + |
| 758 | + if (!($hour instanceof NumeralType)) { |
| 759 | + $hour = self::decimal($hour); |
| 760 | + } |
| 761 | + |
| 762 | + $map = ["hour" => $hour]; |
| 763 | + |
| 764 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 765 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 766 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 767 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 768 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 769 | + |
| 770 | + return FunctionCall::localtime(Query::map($map)); |
| 771 | + } |
| 772 | + |
| 773 | + /** |
| 774 | + * Creates the LocalTime value obtained by parsing a string representation of a temporal value |
| 775 | + * |
| 776 | + * @param string|StringType $localTimeString |
| 777 | + * @return LocalTimeType |
| 778 | + */ |
| 779 | + public static function localTimeString($localTimeString): LocalTimeType { |
| 780 | + if (!($localTimeString instanceof StringType)) { |
| 781 | + $localTimeString = self::string($localTimeString); |
| 782 | + } |
| 783 | + |
| 784 | + return FunctionCall::localtime($localTimeString); |
| 785 | + } |
| 786 | + |
| 787 | + /** |
| 788 | + * Creates the current Time value |
| 789 | + * |
| 790 | + * @param null|string|StringType $timezone |
| 791 | + * @return TimeType |
| 792 | + * |
| 793 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-time-current |
| 794 | + */ |
| 795 | + public static function timeCurrent($timezone = null): TimeType { |
| 796 | + if ($timezone === null) { |
| 797 | + return FunctionCall::time(); |
| 798 | + } |
| 799 | + |
| 800 | + if (!($timezone instanceof StringType)) { |
| 801 | + $timezone = self::string($timezone); |
| 802 | + } |
| 803 | + return FunctionCall::time(Query::map(["timezone" => $timezone])); |
| 804 | + } |
| 805 | + |
| 806 | + /** |
| 807 | + * Creates a Time value with the specified hour, minute, second, millisecond, microsecond, nanosecond and timezone component values |
| 808 | + * |
| 809 | + * @param int|NumeralType $hour |
| 810 | + * @param null|int|NumeralType $minute |
| 811 | + * @param null|int|NumeralType $second |
| 812 | + * @param null|int|NumeralType $millisecond |
| 813 | + * @param null|int|NumeralType $microsecond |
| 814 | + * @param null|int|NumeralType $nanosecond |
| 815 | + * @param null|string|StringType $timezone |
| 816 | + * @return TimeType |
| 817 | + * |
| 818 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-time-create |
| 819 | + */ |
| 820 | + public static function time($hour, $minute = null, $second = null, $millisecond = null, $microsecond = null, $nanosecond = null, $timezone = null): TimeType { |
| 821 | + $setVariables = self::checkOrderAndConvert2Numeral([ |
| 822 | + "minute" => $minute, |
| 823 | + "second" => $second, |
| 824 | + "millisecond" => $millisecond, |
| 825 | + "microsecond" => $microsecond, |
| 826 | + "nanosecond" => $nanosecond |
| 827 | + ]); |
| 828 | + |
| 829 | + if (!($hour instanceof NumeralType)) { |
| 830 | + $hour = self::decimal($hour); |
| 831 | + } |
| 832 | + |
| 833 | + $map = ["hour" => $hour]; |
| 834 | + |
| 835 | + if ($minute !== null) $map["minute"] = $setVariables["minute"]; |
| 836 | + if ($second !== null) $map["second"] = $setVariables["second"]; |
| 837 | + if ($millisecond !== null) $map["millisecond"] = $setVariables["millisecond"]; |
| 838 | + if ($microsecond !== null) $map["microsecond"] = $setVariables["microsecond"]; |
| 839 | + if ($nanosecond !== null) $map["nanosecond"] = $setVariables["nanosecond"]; |
| 840 | + if ($timezone !== null) { |
| 841 | + if (!($timezone instanceof StringType)) { |
| 842 | + $timezone = self::string($timezone); |
| 843 | + } |
| 844 | + $map["timezone"] = $timezone; |
| 845 | + } |
| 846 | + |
| 847 | + return FunctionCall::time(Query::map($map)); |
| 848 | + } |
| 849 | + |
| 850 | + /** |
| 851 | + * Creates the Time value obtained by parsing a string representation of a temporal value |
| 852 | + * |
| 853 | + * @param string|StringType $timeString |
| 854 | + * @return TimeType |
| 855 | + * |
| 856 | + * @see https://neo4j.com/docs/cypher-manual/current/functions/temporal/#functions-time-create-string |
| 857 | + */ |
| 858 | + public static function timeString($timeString): TimeType { |
| 859 | + if (!($timeString instanceof StringType)) { |
| 860 | + $timeString = self::string($timeString); |
| 861 | + } |
| 862 | + return FunctionCall::time($timeString); |
| 863 | + } |
497 | 864 |
|
498 | 865 | /**
|
499 | 866 | * Creates a 2d cartesian point.
|
|
0 commit comments