• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wol-soft / php-json-schema-model-generator / 26579622341

28 May 2026 02:03PM UTC coverage: 98.865% (-0.05%) from 98.912%
26579622341

push

github

web-flow
Merge pull request #143 from wol-soft/fix/issue-130-duplicate-ref-builder-methods

Fix duplicate builder methods when two properties share a $ref (#130)

10 of 24 new or added lines in 1 file covered. (41.67%)

5921 of 5989 relevant lines covered (98.86%)

586.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.29
/src/Model/Property/PropertyProxy.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Model\Property;
6

7
use PHPModelGenerator\Exception\SchemaException;
8
use PHPModelGenerator\Model\Attributes\PhpAttribute;
9
use PHPModelGenerator\Model\GeneratorConfiguration;
10
use PHPModelGenerator\Model\Schema;
11
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
12
use PHPModelGenerator\Model\SchemaDefinition\ResolvedDefinitionsCollection;
13
use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
14
use PHPModelGenerator\PropertyProcessor\Decorator\Property\PropertyDecoratorInterface;
15
use PHPModelGenerator\PropertyProcessor\Decorator\TypeHint\TypeHintDecoratorInterface;
16

17
/**
18
 * Class PropertyProxy
19
 *
20
 * @package PHPModelGenerator\Model
21
 */
22
class PropertyProxy extends AbstractProperty
23
{
24
    /**
25
     * PropertyProxy constructor.
26
     *
27
     * @param string $name The name must be provided separately as the name is not bound to the structure of a
28
     * referenced schema. Consequently, two properties with different names can refer an identical schema utilizing the
29
     * PropertyProxy. By providing a name to each of the proxies the resulting properties will get the correct names.
30
     *
31
     * @throws SchemaException
32
     */
33
    public function __construct(
943✔
34
        string $name,
35
        JsonSchema $jsonSchema,
36
        protected ResolvedDefinitionsCollection $definitionsCollection,
37
        protected string $key,
38
    ) {
39
        parent::__construct($name, $jsonSchema);
943✔
40
    }
41

42
    /**
43
     * Get the property out of the resolved definitions collection to proxy function calls
44
     */
45
    protected function getProperty(): PropertyInterface
943✔
46
    {
47
        return $this->definitionsCollection->offsetGet($this->key);
943✔
48
    }
49

50
    /**
51
     * @inheritdoc
52
     */
53
    public function getType(bool $outputType = false): ?PropertyType
229✔
54
    {
55
        return $this->getProperty()->getType($outputType);
229✔
56
    }
57

58
    /**
59
     * @inheritdoc
60
     */
61
    public function setType(
5✔
62
        ?PropertyType $type = null,
63
        ?PropertyType $outputType = null,
64
        bool $reset = false,
65
    ): PropertyInterface {
66
        $this->getProperty()->setType($type, $outputType, $reset);
5✔
67

68
        return $this;
5✔
69
    }
70

71
    /**
72
     * @inheritdoc
73
     */
74
    public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
443✔
75
    {
76
        return $this->getProperty()->getTypeHint($outputType, $skipDecorators);
443✔
77
    }
78

79
    /**
80
     * @inheritdoc
81
     */
82
    public function addTypeHintDecorator(TypeHintDecoratorInterface $typeHintDecorator): PropertyInterface
1✔
83
    {
84
        $this->getProperty()->addTypeHintDecorator($typeHintDecorator);
1✔
85

86
        return $this;
1✔
87
    }
88

89
    /**
90
     * @inheritdoc
91
     */
92
    public function getDescription(): string
14✔
93
    {
94
        return $this->getProperty()->getDescription();
14✔
95
    }
96

97
    public function getComment(): ?string
14✔
98
    {
99
        return $this->getProperty()->getComment();
14✔
100
    }
101

102
    public function setComment(string $comment): PropertyInterface
×
103
    {
104
        $this->getProperty()->setComment($comment);
×
105

106
        return $this;
×
107
    }
108

109
    public function getExamples(): array
14✔
110
    {
111
        return $this->getProperty()->getExamples();
14✔
112
    }
113

114
    public function setExamples(array $examples): PropertyInterface
×
115
    {
116
        $this->getProperty()->setExamples($examples);
×
117

118
        return $this;
×
119
    }
120

121
    /**
122
     * @inheritdoc
123
     */
124
    public function addValidator(
44✔
125
        PropertyValidatorInterface $validator,
126
        int $priority = 99,
127
        ?string $sourceKey = null,
128
    ): PropertyInterface {
129
        $this->getProperty()->addValidator($validator, $priority, $sourceKey);
44✔
130

131
        return $this;
44✔
132
    }
133

134
    /**
135
     * @inheritdoc
136
     */
137
    public function getValidators(): array
19✔
138
    {
139
        return $this->getProperty()->getValidators();
19✔
140
    }
141

142
    /**
143
     * @inheritdoc
144
     */
145
    public function filterValidators(callable $filter): PropertyInterface
931✔
146
    {
147
        $this->getProperty()->filterValidators($filter);
931✔
148

149
        return $this;
931✔
150
    }
151

152
    /**
153
     * @inheritdoc
154
     */
155
    public function getOrderedValidators(): array
921✔
156
    {
157
        return array_map(
921✔
158
            fn(PropertyValidatorInterface $propertyValidator): PropertyValidatorInterface =>
921✔
159
                $propertyValidator->withProperty($this),
921✔
160
            $this->getProperty()->getOrderedValidators(),
921✔
161
        );
921✔
162
    }
163

164
    /**
165
     * @inheritdoc
166
     */
167
    public function addDecorator(PropertyDecoratorInterface $decorator): PropertyInterface
×
168
    {
NEW
169
        $this->getProperty()->addDecorator($decorator);
×
170

NEW
171
        return $this;
×
172
    }
173

174
    /**
175
     * @inheritdoc
176
     */
177
    public function filterDecorators(callable $filter): PropertyInterface
×
178
    {
NEW
179
        $this->getProperty()->filterDecorators($filter);
×
180

NEW
181
        return $this;
×
182
    }
183

184
    /**
185
     * @inheritdoc
186
     */
187
    public function resolveDecorator(string $input, bool $nestedProperty): string
679✔
188
    {
189
        foreach ($this->getProperty()->getDecorators() as $decorator) {
679✔
190
            $input = $decorator->decorate($input, $this, $nestedProperty);
679✔
191
        }
192

193
        return $input;
679✔
194
    }
195

196
    /**
197
     * @inheritdoc
198
     */
199
    public function getDecorators(): array
921✔
200
    {
201
        return $this->getProperty()->getDecorators();
921✔
202
    }
203

204
    /**
205
     * @inheritdoc
206
     */
207
    public function setRequired(bool $isPropertyRequired): PropertyInterface
×
208
    {
NEW
209
        $this->getProperty()->setRequired($isPropertyRequired);
×
210

NEW
211
        return $this;
×
212
    }
213

214
    /**
215
     * @inheritdoc
216
     */
217
    public function isRequired(): bool
212✔
218
    {
219
        return $this->getProperty()->isRequired();
212✔
220
    }
221

222
    /**
223
     * @inheritdoc
224
     */
225
    public function setReadOnly(bool $isPropertyReadOnly): PropertyInterface
1✔
226
    {
227
        $this->getProperty()->setReadOnly($isPropertyReadOnly);
1✔
228

229
        return $this;
1✔
230
    }
231

232
    /**
233
     * @inheritdoc
234
     */
235
    public function isReadOnly(): bool
14✔
236
    {
237
        return $this->getProperty()->isReadOnly();
14✔
238
    }
239

240
    /**
241
     * @inheritdoc
242
     */
243
    public function setWriteOnly(bool $isPropertyWriteOnly): PropertyInterface
×
244
    {
NEW
245
        $this->getProperty()->setWriteOnly($isPropertyWriteOnly);
×
246

NEW
247
        return $this;
×
248
    }
249

250
    /**
251
     * @inheritdoc
252
     */
253
    public function isWriteOnly(): bool
14✔
254
    {
255
        return $this->getProperty()->isWriteOnly();
14✔
256
    }
257

258
    /**
259
     * @inheritdoc
260
     */
261
    public function setDefaultValue($defaultValue, bool $raw = false): PropertyInterface
×
262
    {
NEW
263
        $this->getProperty()->setDefaultValue($defaultValue, $raw);
×
264

NEW
265
        return $this;
×
266
    }
267

268
    /**
269
     * @inheritdoc
270
     */
271
    public function getDefaultValue(): ?string
18✔
272
    {
273
        return $this->getProperty()->getDefaultValue();
18✔
274
    }
275

276
    /**
277
     * @inheritdoc
278
     */
279
    public function setNestedSchema(Schema $schema): PropertyInterface
×
280
    {
NEW
281
        $this->getProperty()->setNestedSchema($schema);
×
282

NEW
283
        return $this;
×
284
    }
285

286
    /**
287
     * @inheritdoc
288
     */
289
    public function getNestedSchema(): ?Schema
836✔
290
    {
291
        return $this->getProperty()->getNestedSchema();
836✔
292
    }
293

294
    /**
295
     * @inheritdoc
296
     */
297
    public function getJsonSchema(): JsonSchema
5✔
298
    {
299
        return $this->getProperty()->getJsonSchema();
5✔
300
    }
301

302
    /**
303
     * @inheritdoc
304
     */
305
    public function setInternal(bool $isPropertyInternal): PropertyInterface
×
306
    {
NEW
307
        $this->getProperty()->setInternal($isPropertyInternal);
×
308

NEW
309
        return $this;
×
310
    }
311

312
    /**
313
     * @inheritdoc
314
     */
315
    public function isInternal(): bool
14✔
316
    {
317
        return $this->getProperty()->isInternal();
14✔
318
    }
319

320
    /**
321
     * @inheritdoc
322
     */
323
    public function addAttribute(
×
324
        PhpAttribute $attribute,
325
        ?GeneratorConfiguration $generatorConfiguration = null,
326
        ?int $enablementFlag = null,
327
    ): static {
328
        $this->getProperty()->addAttribute($attribute);
×
329

330
        return $this;
×
331
    }
332

333
    /**
334
     * @inheritdoc
335
     */
336
    public function getAttributes(): array
14✔
337
    {
338
        return $this->getProperty()->getAttributes();
14✔
339
    }
340
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc