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

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

03 Apr 2026 01:13AM UTC coverage: 98.248% (-0.4%) from 98.654%
23929375043

Pull #125

github

Enno Woortmann
attribute tests
Pull Request #125: attributes

1496 of 1526 new or added lines in 66 files covered. (98.03%)

4 existing lines in 3 files now uncovered.

4374 of 4452 relevant lines covered (98.25%)

620.23 hits per line

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

60.32
/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(
811✔
34
        string $name,
35
        JsonSchema $jsonSchema,
36
        protected ResolvedDefinitionsCollection $definitionsCollection,
37
        protected string $key,
38
    ) {
39
        parent::__construct($name, $jsonSchema);
811✔
40
    }
41

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

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

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

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

77
    /**
78
     * @inheritdoc
79
     */
80
    public function addTypeHintDecorator(TypeHintDecoratorInterface $typeHintDecorator): PropertyInterface
×
81
    {
82
        return $this->getProperty()->addTypeHintDecorator($typeHintDecorator);
×
83
    }
84

85
    /**
86
     * @inheritdoc
87
     */
88
    public function getDescription(): string
13✔
89
    {
90
        return $this->getProperty()->getDescription();
13✔
91
    }
92

93
    /**
94
     * @inheritdoc
95
     */
96
    public function addValidator(PropertyValidatorInterface $validator, int $priority = 99): PropertyInterface
×
97
    {
98
        return $this->getProperty()->addValidator($validator, $priority);
×
99
    }
100

101
    /**
102
     * @inheritdoc
103
     */
104
    public function getValidators(): array
13✔
105
    {
106
        return $this->getProperty()->getValidators();
13✔
107
    }
108

109
    /**
110
     * @inheritdoc
111
     */
112
    public function filterValidators(callable $filter): PropertyInterface
799✔
113
    {
114
        return $this->getProperty()->filterValidators($filter);
799✔
115
    }
116

117
    /**
118
     * @inheritdoc
119
     */
120
    public function getOrderedValidators(): array
803✔
121
    {
122
        return array_map(
803✔
123
            fn(PropertyValidatorInterface $propertyValidator): PropertyValidatorInterface =>
803✔
124
                $propertyValidator->withProperty($this),
803✔
125
            $this->getProperty()->getOrderedValidators(),
803✔
126
        );
803✔
127
    }
128

129
    /**
130
     * @inheritdoc
131
     */
132
    public function addDecorator(PropertyDecoratorInterface $decorator): PropertyInterface
×
133
    {
134
        return $this->getProperty()->addDecorator($decorator);
×
135
    }
136

137
    /**
138
     * @inheritdoc
139
     */
140
    public function filterDecorators(callable $filter): PropertyInterface
×
141
    {
142
        return $this->getProperty()->filterDecorators($filter);
×
143
    }
144

145
    /**
146
     * @inheritdoc
147
     */
148
    public function resolveDecorator(string $input, bool $nestedProperty): string
662✔
149
    {
150
        foreach ($this->getProperty()->getDecorators() as $decorator) {
662✔
151
            $input = $decorator->decorate($input, $this, $nestedProperty);
662✔
152
        }
153

154
        return $input;
662✔
155
    }
156

157
    /**
158
     * @inheritdoc
159
     */
160
    public function getDecorators(): array
803✔
161
    {
162
        return $this->getProperty()->getDecorators();
803✔
163
    }
164

165
    /**
166
     * @inheritdoc
167
     */
168
    public function setRequired(bool $isPropertyRequired): PropertyInterface
×
169
    {
170
        return $this->getProperty()->setRequired($isPropertyRequired);
×
171
    }
172

173
    /**
174
     * @inheritdoc
175
     */
176
    public function isRequired(): bool
141✔
177
    {
178
        return $this->getProperty()->isRequired();
141✔
179
    }
180

181
    /**
182
     * @inheritdoc
183
     */
184
    public function setReadOnly(bool $isPropertyReadOnly): PropertyInterface
×
185
    {
186
        return $this->getProperty()->setReadOnly($isPropertyReadOnly);
×
187
    }
188

189
    /**
190
     * @inheritdoc
191
     */
192
    public function isReadOnly(): bool
13✔
193
    {
194
        return $this->getProperty()->isReadOnly();
13✔
195
    }
196

197
    /**
198
     * @inheritdoc
199
     */
200
    public function setDefaultValue($defaultValue, bool $raw = false): PropertyInterface
×
201
    {
202
        return $this->getProperty()->setDefaultValue($defaultValue, $raw);
×
203
    }
204

205
    /**
206
     * @inheritdoc
207
     */
208
    public function getDefaultValue(): ?string
13✔
209
    {
210
        return $this->getProperty()->getDefaultValue();
13✔
211
    }
212

213
    /**
214
     * @inheritdoc
215
     */
216
    public function setNestedSchema(Schema $schema): PropertyInterface
×
217
    {
218
        return $this->getProperty()->setNestedSchema($schema);
×
219
    }
220

221
    /**
222
     * @inheritdoc
223
     */
224
    public function getNestedSchema(): ?Schema
716✔
225
    {
226
        return $this->getProperty()->getNestedSchema();
716✔
227
    }
228

229
    /**
230
     * @inheritdoc
231
     */
232
    public function getJsonSchema(): JsonSchema
×
233
    {
234
        return $this->getProperty()->getJsonSchema();
×
235
    }
236

237
    /**
238
     * @inheritdoc
239
     */
240
    public function setInternal(bool $isPropertyInternal): PropertyInterface
×
241
    {
242
        return $this->getProperty()->setInternal($isPropertyInternal);
×
243
    }
244

245
    /**
246
     * @inheritdoc
247
     */
248
    public function isInternal(): bool
13✔
249
    {
250
        return $this->getProperty()->isInternal();
13✔
251
    }
252

253
    /**
254
     * @inheritdoc
255
     */
NEW
256
    public function addAttribute(
×
257
        PhpAttribute $attribute,
258
        ?GeneratorConfiguration $generatorConfiguration = null,
259
        ?int $enablementFlag = null,
260
    ): static {
UNCOV
261
        $this->getProperty()->addAttribute($attribute);
×
262

263
        return $this;
×
264
    }
265

266
    /**
267
     * @inheritdoc
268
     */
269
    public function getAttributes(): array
13✔
270
    {
271
        return $this->getProperty()->getAttributes();
13✔
272
    }
273
}
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