PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DoctrineExtensions/Query/Mysql/Sin.php

http://github.com/beberlei/DoctrineExtensions
PHP | 46 lines | 22 code | 13 blank | 11 comment | 0 complexity | 089e54fbc96b632254a3b45175d82e48 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * DoctrineExtensions Mysql Function Pack
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * If you did not receive a copy of the license and are unable to
  10. * obtain it through the world-wide-web, please send an email
  11. * to kontakt@beberlei.de so I can send you a copy immediately.
  12. */
  13. namespace DoctrineExtensions\Query\Mysql;
  14. use Doctrine\ORM\Query\AST\Functions\FunctionNode,
  15. Doctrine\ORM\Query\Lexer;
  16. class Sin extends FunctionNode
  17. {
  18. public $arithmeticExpression;
  19. public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
  20. {
  21. return 'SIN(' . $sqlWalker->walkSimpleArithmeticExpression(
  22. $this->arithmeticExpression
  23. ) . ')';
  24. }
  25. public function parse(\Doctrine\ORM\Query\Parser $parser)
  26. {
  27. $lexer = $parser->getLexer();
  28. $parser->match(Lexer::T_IDENTIFIER);
  29. $parser->match(Lexer::T_OPEN_PARENTHESIS);
  30. $this->arithmeticExpression = $parser->SimpleArithmeticExpression();
  31. $parser->match(Lexer::T_CLOSE_PARENTHESIS);
  32. }
  33. }