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

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

03 Dec 2025 04:23PM UTC coverage: 98.665%. Remained the same
19900971490

push

github

wol-soft
Make code output stable across multiple runs (#41)

2 of 2 new or added lines in 2 files covered. (100.0%)

3399 of 3445 relevant lines covered (98.66%)

566.51 hits per line

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

64.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\SchemaDefinition\JsonSchema;
9
use PHPModelGenerator\Model\SchemaDefinition\ResolvedDefinitionsCollection;
10
use PHPModelGenerator\Model\Schema;
11
use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
12
use PHPModelGenerator\PropertyProcessor\Decorator\Property\PropertyDecoratorInterface;
13
use PHPModelGenerator\PropertyProcessor\Decorator\TypeHint\TypeHintDecoratorInterface;
14

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

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

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

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

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

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

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

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

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

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

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

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

135
    /**
136
     * @inheritdoc
137
     */
138
    public function resolveDecorator(string $input, bool $nestedProperty): string
502✔
139
    {
140
        foreach ($this->getProperty()->getDecorators() as $decorator) {
502✔
141
            $input = $decorator->decorate($input, $this, $nestedProperty);
502✔
142
        }
143

144
        return $input;
502✔
145
    }
146

147
    /**
148
     * @inheritdoc
149
     */
150
    public function getDecorators(): array
643✔
151
    {
152
        return $this->getProperty()->getDecorators();
643✔
153
    }
154

155
    /**
156
     * @inheritdoc
157
     */
158
    public function setRequired(bool $isPropertyRequired): PropertyInterface
×
159
    {
160
        return $this->getProperty()->setRequired($isPropertyRequired);
×
161
    }
162

163
    /**
164
     * @inheritdoc
165
     */
166
    public function isRequired(): bool
6✔
167
    {
168
        return $this->getProperty()->isRequired();
6✔
169
    }
170

171
    /**
172
     * @inheritdoc
173
     */
174
    public function setReadOnly(bool $isPropertyReadOnly): PropertyInterface
×
175
    {
176
        return $this->getProperty()->setReadOnly($isPropertyReadOnly);
×
177
    }
178

179
    /**
180
     * @inheritdoc
181
     */
182
    public function isReadOnly(): bool
6✔
183
    {
184
        return $this->getProperty()->isReadOnly();
6✔
185
    }
186

187
    /**
188
     * @inheritdoc
189
     */
190
    public function setDefaultValue($defaultValue, bool $raw = false): PropertyInterface
×
191
    {
192
        return $this->getProperty()->setDefaultValue($defaultValue, $raw);
×
193
    }
194

195
    /**
196
     * @inheritdoc
197
     */
198
    public function getDefaultValue(): ?string
6✔
199
    {
200
        return $this->getProperty()->getDefaultValue();
6✔
201
    }
202

203
    /**
204
     * @inheritdoc
205
     */
206
    public function setNestedSchema(Schema $schema): PropertyInterface
×
207
    {
208
        return $this->getProperty()->setNestedSchema($schema);
×
209
    }
210

211
    /**
212
     * @inheritdoc
213
     */
214
    public function getNestedSchema(): ?Schema
559✔
215
    {
216
        return $this->getProperty()->getNestedSchema();
559✔
217
    }
218

219
    /**
220
     * @inheritdoc
221
     */
222
    public function getJsonSchema(): JsonSchema
×
223
    {
224
        return $this->getProperty()->getJsonSchema();
×
225
    }
226

227
    /**
228
     * @inheritdoc
229
     */
230
    public function setInternal(bool $isPropertyInternal): PropertyInterface
×
231
    {
232
        return $this->getProperty()->setInternal($isPropertyInternal);
×
233
    }
234

235
    /**
236
     * @inheritdoc
237
     */
238
    public function isInternal(): bool
6✔
239
    {
240
        return $this->getProperty()->isInternal();
6✔
241
    }
242
}
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

© 2025 Coveralls, Inc