nark3d /
PhalueObjects
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace BestServedCold\PhalueObjects\Mathematical\Operator; |
||
| 4 | |||
| 5 | use BestServedCold\PhalueObjects\Contract\ValueObject as ValueObjectInterface; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class ArithmeticTrait |
||
| 9 | * |
||
| 10 | * @package BestServedCold\PhalueObjects\Mathematical\Operator |
||
| 11 | * @author Adam Lewis <[email protected]> |
||
| 12 | * @copyright Copyright (c) 2015 Best Served Cold Media Limited |
||
| 13 | * @license http://http://opensource.org/licenses/GPL-3.0 GPL License |
||
| 14 | * @link http://bestservedcold.com |
||
| 15 | * @since 0.0.1-alpha |
||
| 16 | * @version 0.0.2-alpha |
||
| 17 | */ |
||
| 18 | trait ArithmeticTrait |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @return mixed |
||
| 22 | */ |
||
| 23 | public abstract function getValue(); |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return static |
||
| 27 | */ |
||
| 28 | 7 | public function absolute() |
|
| 29 | { |
||
| 30 | 7 | return new static(abs($this->getValue())); |
|
|
0 ignored issues
–
show
|
|||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return static |
||
| 35 | */ |
||
| 36 | 5 | public function makeNegative() |
|
| 37 | { |
||
| 38 | 5 | return new static(-$this->absolute()->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with -$this->absolute()->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return static |
||
| 43 | */ |
||
| 44 | 4 | public function makePositive() |
|
| 45 | { |
||
| 46 | 4 | return new static($this->absolute()->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->absolute()->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return static |
||
| 51 | */ |
||
| 52 | 2 | public function reversePolarity() |
|
| 53 | { |
||
| 54 | 2 | if ($this->isNegative() || $this->isZero()) { |
|
|
0 ignored issues
–
show
It seems like
isNegative() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the Loading history...
It seems like
isZero() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the Loading history...
|
|||
| 55 | 2 | return new static($this->makePositive()->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->makePositive()->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 56 | } else { |
||
| 57 | 2 | return new static($this->makeNegative()->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->makeNegative()->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param ValueObjectInterface $object |
||
| 63 | * @return static |
||
| 64 | */ |
||
| 65 | 18 | public function add(ValueObjectInterface $object) |
|
| 66 | { |
||
| 67 | 18 | return new static($this->getValue() + $object->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() + $object->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param ValueObjectInterface $object |
||
| 72 | * @return static |
||
| 73 | */ |
||
| 74 | 1 | public function subtract(ValueObjectInterface $object) |
|
| 75 | { |
||
| 76 | 1 | return new static($this->getValue() - $object->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() - $object->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param ValueObjectInterface $object |
||
| 81 | * @return static |
||
| 82 | */ |
||
| 83 | 18 | public function multiply(ValueObjectInterface $object) |
|
| 84 | { |
||
| 85 | 18 | return new static($this->getValue() * $object->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() * $object->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param ValueObjectInterface $object |
||
| 90 | * @return static |
||
| 91 | */ |
||
| 92 | 1 | public function divide(ValueObjectInterface $object) |
|
| 93 | { |
||
| 94 | 1 | return new static($this->getValue() / $object->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() / $object->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param ValueObjectInterface $object |
||
| 99 | * @return static |
||
| 100 | */ |
||
| 101 | 1 | public function modulus(ValueObjectInterface $object) |
|
| 102 | { |
||
| 103 | 1 | return new static($this->getValue() % $object->getValue()); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() % $object->getValue().
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @param ValueObjectInterface $object |
||
| 108 | * @return static |
||
| 109 | */ |
||
| 110 | 1 | public function exponentiation(ValueObjectInterface $object) |
|
| 111 | { |
||
| 112 | 1 | return new static(pow($this->getValue(), $object->getValue())); |
|
|
0 ignored issues
–
show
The call to
ArithmeticTrait::__construct() has too many arguments starting with pow($this->getValue(), $object->getValue()).
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the Loading history...
|
|||
| 113 | } |
||
| 114 | } |
||
| 115 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.