-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathJsonOptions.php
More file actions
96 lines (81 loc) · 2.59 KB
/
JsonOptions.php
File metadata and controls
96 lines (81 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
declare(strict_types=1);
namespace Laminas\Serializer\Adapter;
use Laminas\Json\Json as LaminasJson;
use Laminas\Serializer\Exception;
final class JsonOptions extends AdapterOptions
{
protected bool $cycleCheck = false;
protected bool $enableJsonExprFinder = false;
/** @var LaminasJson::TYPE_* */
protected int $objectDecodeType = LaminasJson::TYPE_ARRAY;
public function setAssocArray(bool $flag): void
{
$this->setObjectDecodeType($flag ? LaminasJson::TYPE_ARRAY : LaminasJson::TYPE_OBJECT);
}
public function isAssocArray(): bool
{
return $this->getObjectDecodeType() === LaminasJson::TYPE_ARRAY;
}
/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function setCycleCheck(bool $flag): void
{
$this->cycleCheck = $flag;
}
/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function getCycleCheck(): bool
{
return $this->cycleCheck;
}
/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function setEnableJsonExprFinder(bool $flag): void
{
$this->enableJsonExprFinder = $flag;
}
/**
* @deprecated Since 3.3.0 - This method will be removed in version 4.0 without replacement.
*/
public function getEnableJsonExprFinder(): bool
{
return $this->enableJsonExprFinder;
}
/**
* @deprecated Use the `setAssocArray` method
*
* @see setAssocArray()
*
* @param LaminasJson::TYPE_* $type
* @throws Exception\InvalidArgumentException
*/
public function setObjectDecodeType(int $type): void
{
/**
* @psalm-suppress DocblockTypeContradiction Due to the way how the options for plugins work, i.e. using
* {@see AbstractOptions::setFromArray()}, having an additional check
* here can provide more detailed errors.
*/
if ($type !== LaminasJson::TYPE_ARRAY && $type !== LaminasJson::TYPE_OBJECT) {
throw new Exception\InvalidArgumentException(
'Unknown decode type: ' . $type
);
}
$this->objectDecodeType = $type;
}
/**
* @deprecated Use the `isAssocArray` method
*
* @see isAssocArray()
*
* @return LaminasJson::TYPE_*
*/
public function getObjectDecodeType(): int
{
return $this->objectDecodeType;
}
}