PageRenderTime 37ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/exprlib/src/exprlib/contexts/scope/Pow.php

https://bitbucket.org/furyfire/jabberbot
PHP | 19 lines | 15 code | 4 blank | 0 comment | 2 complexity | a019e9034e99aefb3d346426d09fbc3b MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. namespace exprlib\contexts\scope;
  3. use exprlib\contexts\Scope;
  4. use exprlib\exceptions\ParsingException;
  5. class Pow extends Scope
  6. {
  7. public function evaluate()
  8. {
  9. $result = parent::evaluate();
  10. if (!is_array($result) || count($result) !== 2) {
  11. throw new ParsingException('Power must have 2 arguments, ex: power(10,2)');
  12. }
  13. return pow($result[0], $result[1]);
  14. }
  15. }