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

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

17 Oct 2023 10:20AM UTC coverage: 98.843% (+0.06%) from 98.786%
6545814266

push

github

web-flow
Merge pull request #73 from wol-soft/enumPostProcessor

Enum post processor

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

2990 of 3025 relevant lines covered (98.84%)

519.56 hits per line

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

70.59
/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
    /** @var string */
23
    protected $key;
24
    /** @var ResolvedDefinitionsCollection */
25
    protected $definitionsCollection;
26

27
    /**
28
     * PropertyProxy constructor.
29
     *
30
     * @param string $name The name must be provided separately as the name is not bound to the structure of a
31
     * referenced schema. Consequently, two properties with different names can refer an identical schema utilizing the
32
     * PropertyProxy. By providing a name to each of the proxies the resulting properties will get the correct names.
33
     * @param JsonSchema $jsonSchema
34
     * @param ResolvedDefinitionsCollection $definitionsCollection
35
     * @param string $key
36
     *
37
     * @throws SchemaException
38
     */
39
    public function __construct(
40
        string $name,
41
        JsonSchema $jsonSchema,
42
        ResolvedDefinitionsCollection $definitionsCollection,
43
        string $key
44
    ) {
45
        parent::__construct($name, $jsonSchema);
632✔
46

47
        $this->key = $key;
632✔
48
        $this->definitionsCollection = $definitionsCollection;
632✔
49
    }
50

51
    /**
52
     * Get the property out of the resolved definitions collection to proxy function calls
53
     *
54
     * @return PropertyInterface
55
     */
56
    protected function getProperty(): PropertyInterface
57
    {
58
        return $this->definitionsCollection->offsetGet($this->key);
632✔
59
    }
60

61
    /**
62
     * @inheritdoc
63
     */
64
    public function getType(bool $outputType = false): ?PropertyType
65
    {
66
        return $this->getProperty()->getType($outputType);
538✔
67
    }
68

69
    /**
70
     * @inheritdoc
71
     */
72
    public function setType(
73
        PropertyType $type = null,
74
        PropertyType $outputType = null,
75
        bool $reset = false
76
    ): PropertyInterface {
77
        return $this->getProperty()->setType($type, $outputType);
×
78
    }
79

80
    /**
81
     * @inheritdoc
82
     */
83
    public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
84
    {
85
        return $this->getProperty()->getTypeHint($outputType, $skipDecorators);
344✔
86
    }
87

88
    /**
89
     * @inheritdoc
90
     */
91
    public function addTypeHintDecorator(TypeHintDecoratorInterface $typeHintDecorator): PropertyInterface
92
    {
93
        return $this->getProperty()->addTypeHintDecorator($typeHintDecorator);
×
94
    }
95

96
    /**
97
     * @inheritdoc
98
     */
99
    public function getDescription(): string
100
    {
101
        return $this->getProperty()->getDescription();
6✔
102
    }
103

104
    /**
105
     * @inheritdoc
106
     */
107
    public function addValidator(PropertyValidatorInterface $validator, int $priority = 99): PropertyInterface
108
    {
109
        return $this->getProperty()->addValidator($validator, $priority);
×
110
    }
111

112
    /**
113
     * @inheritdoc
114
     */
115
    public function getValidators(): array
116
    {
117
        return $this->getProperty()->getValidators();
6✔
118
    }
119

120
    /**
121
     * @inheritdoc
122
     */
123
    public function filterValidators(callable $filter): PropertyInterface
124
    {
125
        return $this->getProperty()->filterValidators($filter);
627✔
126
    }
127

128
    /**
129
     * @inheritdoc
130
     */
131
    public function getOrderedValidators(): array
132
    {
133
        return array_map(
631✔
134
            function (PropertyValidatorInterface $propertyValidator): PropertyValidatorInterface {
631✔
135
                return $propertyValidator->withProperty($this);
626✔
136
            },
631✔
137
            $this->getProperty()->getOrderedValidators()
631✔
138
        );
631✔
139
    }
140

141
    /**
142
     * @inheritdoc
143
     */
144
    public function addDecorator(PropertyDecoratorInterface $decorator): PropertyInterface
145
    {
146
        return $this->getProperty()->addDecorator($decorator);
×
147
    }
148

149
    /**
150
     * @inheritdoc
151
     */
152
    public function resolveDecorator(string $input, bool $nestedProperty): string
153
    {
154
        foreach ($this->getProperty()->getDecorators() as $decorator) {
496✔
155
            $input = $decorator->decorate($input, $this, $nestedProperty);
496✔
156
        }
157

158
        return $input;
496✔
159
    }
160

161
    /**
162
     * @inheritdoc
163
     */
164
    public function getDecorators(): array
165
    {
166
        return $this->getProperty()->getDecorators();
631✔
167
    }
168

169
    /**
170
     * @inheritdoc
171
     */
172
    public function setRequired(bool $isPropertyRequired): PropertyInterface
173
    {
174
        return $this->getProperty()->setRequired($isPropertyRequired);
×
175
    }
176

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

185
    /**
186
     * @inheritdoc
187
     */
188
    public function setReadOnly(bool $isPropertyReadOnly): PropertyInterface
189
    {
190
        return $this->getProperty()->setReadOnly($isPropertyReadOnly);
×
191
    }
192

193
    /**
194
     * @inheritdoc
195
     */
196
    public function isReadOnly(): bool
197
    {
198
        return $this->getProperty()->isReadOnly();
6✔
199
    }
200

201
    /**
202
     * @inheritdoc
203
     */
204
    public function setDefaultValue($defaultValue, bool $raw = false): PropertyInterface
205
    {
206
        return $this->getProperty()->setDefaultValue($defaultValue, $raw);
×
207
    }
208

209
    /**
210
     * @inheritdoc
211
     */
212
    public function getDefaultValue(): ?string
213
    {
214
        return $this->getProperty()->getDefaultValue();
6✔
215
    }
216

217
    /**
218
     * @inheritdoc
219
     */
220
    public function setNestedSchema(Schema $schema): PropertyInterface
221
    {
222
        return $this->getProperty()->setNestedSchema($schema);
×
223
    }
224

225
    /**
226
     * @inheritdoc
227
     */
228
    public function getNestedSchema(): ?Schema
229
    {
230
        return $this->getProperty()->getNestedSchema();
547✔
231
    }
232

233
    /**
234
     * @inheritdoc
235
     */
236
    public function getJsonSchema(): JsonSchema
237
    {
238
        return $this->getProperty()->getJsonSchema();
×
239
    }
240

241
    /**
242
     * @inheritdoc
243
     */
244
    public function setInternal(bool $isPropertyInternal): PropertyInterface
245
    {
246
        return $this->getProperty()->setInternal($isPropertyInternal);
×
247
    }
248

249
    /**
250
     * @inheritdoc
251
     */
252
    public function isInternal(): bool
253
    {
254
        return $this->getProperty()->isInternal();
6✔
255
    }
256
}
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