@@ -55,8 +55,7 @@ |
||
| 55 | 55 | * @class Operator |
| 56 | 56 | * @package Platine\Expression |
| 57 | 57 | */ |
| 58 | -class Operator |
|
| 59 | -{ |
|
| 58 | +class Operator { |
|
| 60 | 59 | /** |
| 61 | 60 | * Number of function argument |
| 62 | 61 | * @var int |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * @class CustomFunction |
| 56 | 56 | * @package Platine\Expression |
| 57 | 57 | */ |
| 58 | -class CustomFunction |
|
| 59 | -{ |
|
| 58 | +class CustomFunction { |
|
| 60 | 59 | /** |
| 61 | 60 | * Number of function argument required |
| 62 | 61 | * @var int |
@@ -68,8 +67,7 @@ discard block |
||
| 68 | 67 | * @param string $name The function name |
| 69 | 68 | * @param callable $function The function to be called |
| 70 | 69 | */ |
| 71 | - public function __construct(protected string $name, protected $function) |
|
| 72 | - { |
|
| 70 | + public function __construct(protected string $name, protected $function) { |
|
| 73 | 71 | $this->name = $name; |
| 74 | 72 | $this->function = $function; |
| 75 | 73 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getVariable(string $name): mixed |
| 180 | 180 | { |
| 181 | - if (! array_key_exists($name, $this->variables)) { |
|
| 181 | + if (!array_key_exists($name, $this->variables)) { |
|
| 182 | 182 | if ($this->variableNotFoundHandler !== null) { |
| 183 | 183 | return call_user_func($this->variableNotFoundHandler, $name); |
| 184 | 184 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'uNeg' => [static fn($a) => 0 - $a, 200, false], |
| 378 | 378 | '*' => [static fn($a, $b) => $a * $b, 180, false], |
| 379 | 379 | '/' => [ |
| 380 | - static function ($a, $b) { |
|
| 380 | + static function($a, $b) { |
|
| 381 | 381 | if ($b == 0) { |
| 382 | 382 | throw new DivisionByZeroException(); |
| 383 | 383 | } |
@@ -407,14 +407,14 @@ discard block |
||
| 407 | 407 | protected function defaultFunctions(): array |
| 408 | 408 | { |
| 409 | 409 | return [ |
| 410 | - 'abs' => static function ($arg) { |
|
| 410 | + 'abs' => static function($arg) { |
|
| 411 | 411 | if ((int) $arg == $arg) { |
| 412 | 412 | return abs(intval($arg)); |
| 413 | 413 | } |
| 414 | 414 | return abs(floatval($arg)); |
| 415 | 415 | }, |
| 416 | 416 | 'array' => static fn(...$args) => $args, |
| 417 | - 'avg' => static function ($arg1, ...$args) { |
|
| 417 | + 'avg' => static function($arg1, ...$args) { |
|
| 418 | 418 | if (is_array($arg1)) { |
| 419 | 419 | if (count($arg1) === 0) { |
| 420 | 420 | throw new InvalidArgumentException('Array must contains at least one element'); |
@@ -426,13 +426,13 @@ discard block |
||
| 426 | 426 | $args = [$arg1, ...array_values($args)]; |
| 427 | 427 | return array_sum($args) / count($args); |
| 428 | 428 | }, |
| 429 | - 'ceil' => static function ($arg) { |
|
| 429 | + 'ceil' => static function($arg) { |
|
| 430 | 430 | if ((int) $arg == $arg) { |
| 431 | 431 | return ceil(intval($arg)); |
| 432 | 432 | } |
| 433 | 433 | return ceil(floatval($arg)); |
| 434 | 434 | }, |
| 435 | - 'floor' => static function ($arg) { |
|
| 435 | + 'floor' => static function($arg) { |
|
| 436 | 436 | if ((int) $arg == $arg) { |
| 437 | 437 | return floor(intval($arg)); |
| 438 | 438 | } |
@@ -448,22 +448,22 @@ discard block |
||
| 448 | 448 | 'sqrt' => static fn($arg) => sqrt(floatval($arg)), |
| 449 | 449 | 'hypot' => static fn($arg1, $arg2) => hypot(floatval($arg1), floatval($arg2)), |
| 450 | 450 | 'intdiv' => static fn($arg1, $arg2) => intdiv(intval($arg1), intval($arg2)), |
| 451 | - 'max' => static function ($arg1, ...$args) { |
|
| 451 | + 'max' => static function($arg1, ...$args) { |
|
| 452 | 452 | if (is_array($arg1) && count($arg1) === 0) { |
| 453 | 453 | throw new InvalidArgumentException('Array must contains at least one element'); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | return max(is_array($arg1) && count($arg1) > 0 ? $arg1 : [$arg1, ...array_values($args)]); |
| 457 | 457 | }, |
| 458 | - 'min' => static function ($arg1, ...$args) { |
|
| 458 | + 'min' => static function($arg1, ...$args) { |
|
| 459 | 459 | if (is_array($arg1) && count($arg1) === 0) { |
| 460 | 460 | throw new InvalidArgumentException('Array must contains at least one element'); |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - return min(is_array($arg1) && count($arg1) > 0 ? $arg1 : [$arg1, ...array_values($args)]); |
|
| 463 | + return min(is_array($arg1) && count($arg1) > 0 ? $arg1 : [$arg1, ...array_values($args)]); |
|
| 464 | 464 | }, |
| 465 | 465 | 'pow' => static fn($arg1, $arg2) => $arg1 ** $arg2, |
| 466 | - 'round' => static function ($arg, int $precision = 0) { |
|
| 466 | + 'round' => static function($arg, int $precision = 0) { |
|
| 467 | 467 | if ((int) $arg == $arg) { |
| 468 | 468 | return round(intval($arg), intval($precision)); |
| 469 | 469 | } |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * @class Executor |
| 56 | 56 | * @package Platine\Expression |
| 57 | 57 | */ |
| 58 | -class Executor |
|
| 59 | -{ |
|
| 58 | +class Executor { |
|
| 60 | 59 | /** |
| 61 | 60 | * The variable list |
| 62 | 61 | * @var array<string, mixed> |
@@ -96,16 +95,14 @@ discard block |
||
| 96 | 95 | /** |
| 97 | 96 | * Create new instance |
| 98 | 97 | */ |
| 99 | - public function __construct() |
|
| 100 | - { |
|
| 98 | + public function __construct() { |
|
| 101 | 99 | $this->addDefaults(); |
| 102 | 100 | } |
| 103 | 101 | |
| 104 | 102 | /** |
| 105 | 103 | * When do clone of this object |
| 106 | 104 | */ |
| 107 | - public function __clone() |
|
| 108 | - { |
|
| 105 | + public function __clone() { |
|
| 109 | 106 | $this->addDefaults(); |
| 110 | 107 | } |
| 111 | 108 | |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * @class Token |
| 52 | 52 | * @package Platine\Expression |
| 53 | 53 | */ |
| 54 | -class Token |
|
| 55 | -{ |
|
| 54 | +class Token { |
|
| 56 | 55 | /** |
| 57 | 56 | * Constants |
| 58 | 57 | */ |