Conditions | 6 |
Paths | 2 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
91 | public function withCustomData(string $name, $value): Payload |
||
92 | { |
||
93 | if ($value && !is_array($value) && !is_scalar($value) && !$value instanceof \JsonSerializable) { |
||
94 | throw new \InvalidArgumentException(sprintf( |
||
95 | 'The custom data value should be a scalar or \JsonSerializable instance, but "%s" given.', |
||
96 | is_object($value) ? get_class($value) : gettype($value) |
||
97 | )); |
||
98 | } |
||
99 | |||
100 | $cloned = clone $this; |
||
101 | |||
102 | $cloned->customData[$name] = $value; |
||
103 | |||
104 | return $cloned; |
||
105 | } |
||
106 | |||
117 |