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