You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ConstantContact/Definition/Base.php
+26-16Lines changed: 26 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -76,26 +76,36 @@ public function __construct(array $initialValues = [])
76
76
*/
77
77
publicfunction__get(string$field) : mixed
78
78
{
79
+
$actualField = $field;
80
+
if (str_starts_with($field, 'cf_'))
81
+
{
82
+
$field = 'cf:custom_field_name';
83
+
}
79
84
if (! isset(static::$fields[$field]))
80
85
{
81
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidField(static::class . "::{$field} is not a valid field");
86
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidField(static::class . "::{$actualField} is not a valid field");
82
87
}
83
88
84
-
$this->setFields[$field] = true;
89
+
$this->setFields[$actualField] = true;
85
90
86
-
return$this->data[$field] ?? null;
91
+
return$this->data[$actualField] ?? null;
87
92
}
88
93
89
94
/**
90
95
* @return mixed value being set to allow for assignment chaining
91
96
*/
92
97
publicfunction__set(string$field, $value)
93
98
{
99
+
$actualField = $field;
100
+
if (str_starts_with($field, 'cf_'))
101
+
{
102
+
$field = 'cf:custom_field_name';
103
+
}
94
104
$expectedType = static::$fields[$field] ?? null;
95
105
96
106
if (null === $expectedType)
97
107
{
98
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidField(static::class . "::{$field} is not a valid field");
108
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidField(static::class . "::{$actualField} is not a valid field");
99
109
}
100
110
101
111
$type = \get_debug_type($value);
@@ -104,7 +114,7 @@ public function __set(string $field, $value)
104
114
{
105
115
if (! \in_array($value, $expectedType))
106
116
{
107
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidValue(static::class . "::{$field} is {$value} but must be one of " . \implode(', ', $expectedType));
117
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidValue(static::class . "::{$actualField} is {$value} but must be one of " . \implode(', ', $expectedType));
108
118
}
109
119
}
110
120
else
@@ -136,7 +146,7 @@ public function __set(string $field, $value)
136
146
137
147
if ($arrayType != $elementType)
138
148
{
139
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidType(static::class . "::{$field} should be an array[{$arrayType}] but index {$index} is of type {$elementType}");
149
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidType(static::class . "::{$actualField} should be an array[{$arrayType}] but index {$index} is of type {$elementType}");
140
150
}
141
151
}
142
152
}
@@ -147,7 +157,7 @@ public function __set(string $field, $value)
147
157
}
148
158
elseif ($expectedType != $type)
149
159
{
150
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidType(static::class . "::{$field} is of type {$type} but should be type {$expectedType}");
160
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidType(static::class . "::{$actualField} is of type {$type} but should be type {$expectedType}");
151
161
}
152
162
}
153
163
@@ -159,16 +169,16 @@ public function __set(string $field, $value)
159
169
{
160
170
if (\count($value) < $minLength)
161
171
{
162
-
thrownew \PHPFUI\ConstantContact\Exception\InvalidLength(static::class . "::{$field} array must have at least {$minLength} values");
172
+
thrownew \PHPFUI\ConstantContact\Exception\InvalidLength(static::class . "::{$actualField} array must have at least {$minLength} values");
0 commit comments