| 1441 |
ariadna |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace PhpOffice\PhpSpreadsheet\Calculation\Information;
|
|
|
4 |
|
|
|
5 |
use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
|
|
|
6 |
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
|
|
7 |
|
|
|
8 |
class ErrorValue
|
|
|
9 |
{
|
|
|
10 |
use ArrayEnabled;
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* IS_ERR.
|
|
|
14 |
*
|
|
|
15 |
* @param mixed $value Value to check
|
|
|
16 |
* Or can be an array of values
|
|
|
17 |
*
|
|
|
18 |
* @return array|bool If an array of numbers is passed as an argument, then the returned result will also be an array
|
|
|
19 |
* with the same dimensions
|
|
|
20 |
*/
|
|
|
21 |
public static function isErr(mixed $value = ''): array|bool
|
|
|
22 |
{
|
|
|
23 |
if (is_array($value)) {
|
|
|
24 |
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
return self::isError($value) && (!self::isNa(($value)));
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* IS_ERROR.
|
|
|
32 |
*
|
|
|
33 |
* @param mixed $value Value to check
|
|
|
34 |
* Or can be an array of values
|
|
|
35 |
*
|
|
|
36 |
* @return array|bool If an array of numbers is passed as an argument, then the returned result will also be an array
|
|
|
37 |
* with the same dimensions
|
|
|
38 |
*/
|
|
|
39 |
public static function isError(mixed $value = '', bool $tryNotImplemented = false): array|bool
|
|
|
40 |
{
|
|
|
41 |
if (is_array($value)) {
|
|
|
42 |
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
if (!is_string($value)) {
|
|
|
46 |
return false;
|
|
|
47 |
}
|
|
|
48 |
if ($tryNotImplemented && $value === Functions::NOT_YET_IMPLEMENTED) {
|
|
|
49 |
return true;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
return in_array($value, ExcelError::ERROR_CODES, true);
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* IS_NA.
|
|
|
57 |
*
|
|
|
58 |
* @param mixed $value Value to check
|
|
|
59 |
* Or can be an array of values
|
|
|
60 |
*
|
|
|
61 |
* @return array|bool If an array of numbers is passed as an argument, then the returned result will also be an array
|
|
|
62 |
* with the same dimensions
|
|
|
63 |
*/
|
|
|
64 |
public static function isNa(mixed $value = ''): array|bool
|
|
|
65 |
{
|
|
|
66 |
if (is_array($value)) {
|
|
|
67 |
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
return $value === ExcelError::NA();
|
|
|
71 |
}
|
|
|
72 |
}
|