|
12 | 12 | namespace Native\Type;
|
13 | 13 |
|
14 | 14 | use InvalidArgumentException;
|
| 15 | +use ZEngine\ClassExtension\Hook\CompareValuesHook; |
| 16 | +use ZEngine\ClassExtension\Hook\DoOperationHook; |
15 | 17 | use ZEngine\ClassExtension\ObjectCompareValuesInterface;
|
16 | 18 | use ZEngine\ClassExtension\ObjectCreateInterface;
|
17 | 19 | use ZEngine\ClassExtension\ObjectCreateTrait;
|
@@ -221,16 +223,18 @@ public function equals(Matrix $another): bool
|
221 | 223 | }
|
222 | 224 |
|
223 | 225 | /**
|
224 |
| - * Performs operation on given object |
| 226 | + * Performs an operation on given object |
225 | 227 | *
|
226 |
| - * @param int $opCode Operation code |
227 |
| - * @param Matrix|int|float $left left side of operation |
228 |
| - * @param Matrix|int|float $right Right side of operation |
| 228 | + * @param DoOperationHook $hook Instance of current hook |
229 | 229 | *
|
230 |
| - * @return Matrix Result of operation value |
| 230 | + * @return mixed Result of operation value |
231 | 231 | */
|
232 |
| - public static function __doOperation(int $opCode, $left, $right): Matrix |
| 232 | + public static function __doOperation(DoOperationHook $hook): Matrix |
233 | 233 | {
|
| 234 | + $left = $hook->getFirst(); |
| 235 | + $right = $hook->getSecond(); |
| 236 | + $opCode = $hook->getOpcode(); |
| 237 | + |
234 | 238 | $isLeftMatrix = $left instanceof Matrix;
|
235 | 239 | $isRightMatrix = $right instanceof Matrix;
|
236 | 240 | $isLeftNumeric = is_numeric($left);
|
@@ -274,13 +278,14 @@ public static function __doOperation(int $opCode, $left, $right): Matrix
|
274 | 278 | /**
|
275 | 279 | * Performs comparison of given object with another value
|
276 | 280 | *
|
277 |
| - * @param mixed $one First side of operation |
278 |
| - * @param mixed $another Another side of operation |
| 281 | + * @param CompareValuesHook $hook Instance of current hook |
279 | 282 | *
|
280 | 283 | * @return int Result of comparison: 1 is greater, -1 is less, 0 is equal
|
281 | 284 | */
|
282 |
| - public static function __compare($one, $another): int |
| 285 | + public static function __compare(CompareValuesHook $hook): int |
283 | 286 | {
|
| 287 | + $one = $hook->getFirst(); |
| 288 | + $another = $hook->getSecond(); |
284 | 289 | if (!($one instanceof Matrix) || !($another instanceof Matrix)) {
|
285 | 290 | throw new \InvalidArgumentException('Matrix can be compared only with another matrix');
|
286 | 291 | }
|
|
0 commit comments