From b2baeae7259af7dfe2d6b4d141a541bb13650964 Mon Sep 17 00:00:00 2001 From: modiamir Date: Fri, 18 Aug 2017 16:15:33 +0430 Subject: [PATCH 1/2] add dist:trusty in travis-ci file --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3a32945d..cefd9a64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ sudo: false +dist: trusty + language: php php: From c45bcccfe29aa9e09611546c6073d9ca9d02167a Mon Sep 17 00:00:00 2001 From: modiamir Date: Fri, 18 Aug 2017 15:34:55 +0430 Subject: [PATCH 2/2] Added a doctrine orm query function for phone number --- Doctrine/ORM/DQL/Functions/Phone.php | 120 +++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Doctrine/ORM/DQL/Functions/Phone.php diff --git a/Doctrine/ORM/DQL/Functions/Phone.php b/Doctrine/ORM/DQL/Functions/Phone.php new file mode 100644 index 00000000..50ff3de1 --- /dev/null +++ b/Doctrine/ORM/DQL/Functions/Phone.php @@ -0,0 +1,120 @@ +format($this->phoneNumber, PhoneNumberFormat::E164)}'"; + } + + /** + * @param \Doctrine\ORM\Query\Parser $parser + */ + public function parse(Parser $parser) + { + $phoneNumber = new PhoneNumber(); + $lexer = $parser->getLexer(); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setCountryCode($lexer->lookahead['value']); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setNationalNumber($lexer->lookahead['value']); + $parser->match(Lexer::T_IDENTIFIER); + + if ( + $lexer->lookahead['type'] == Lexer::T_LEADING && + $lexer->lookahead['value'] == 'Leading' + ) { + $phoneNumber->setItalianLeadingZero(true); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OPEN_PARENTHESIS); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $parser->match(Lexer::T_INPUT_PARAMETER); + $parser->match(Lexer::T_TRUE); + } + + if ( + $lexer->lookahead['type'] == Lexer::T_IDENTIFIER && + $lexer->lookahead['value'] == 'Number' + ) { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_OF); + $parser->match(Lexer::T_LEADING); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setNumberOfLeadingZeros($lexer->lookahead['value']); + $parser->match(Lexer::T_INTEGER); + } + + if ( + $lexer->lookahead['type'] == Lexer::T_IDENTIFIER && + $lexer->lookahead['value'] == 'Extension' + ) { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setExtension($lexer->lookahead['value']); + $parser->match(Lexer::T_INTEGER); + } + + if ( + $lexer->lookahead['type'] == Lexer::T_IDENTIFIER && + $lexer->lookahead['value'] == 'Country' + ) { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setCountryCodeSource($lexer->lookahead['value']); + $parser->match(Lexer::T_INTEGER); + } + + if ( + $lexer->lookahead['type'] == Lexer::T_IDENTIFIER && + $lexer->lookahead['value'] == 'Preferred' + ) { + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_IDENTIFIER); + $parser->match(Lexer::T_INPUT_PARAMETER); + $phoneNumber->setPreferredDomesticCarrierCode($lexer->lookahead['value']); + $parser->match(Lexer::T_STRING); + } + + $parser->match(Lexer::T_CLOSE_PARENTHESIS); + $this->phoneNumber = $phoneNumber; + } +}