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

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

08 Apr 2026 12:55PM UTC coverage: 98.249% (-0.4%) from 98.654%
24136479492

Pull #125

github

wol-soft
Revert "CI"

This reverts commit ef5550c1d.
Pull Request #125: attributes

1507 of 1537 new or added lines in 73 files covered. (98.05%)

4 existing lines in 3 files now uncovered.

4376 of 4454 relevant lines covered (98.25%)

621.28 hits per line

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

57.14
/src/Model/Validator/Factory/SimplePropertyValidatorFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace PHPModelGenerator\Model\Validator\Factory;
6

7
use PHPModelGenerator\Exception\SchemaException;
8
use PHPModelGenerator\Model\Property\PropertyInterface;
9
use PHPModelGenerator\Model\Schema;
10
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
11
use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
12
use PHPModelGenerator\SchemaProcessor\SchemaProcessor;
13

14
abstract class SimplePropertyValidatorFactory extends AbstractValidatorFactory
15
{
16
    public function modify(
1,958✔
17
        SchemaProcessor $schemaProcessor,
18
        Schema $schema,
19
        PropertyInterface $property,
20
        JsonSchema $propertySchema,
21
    ): void {
22
        if (!$this->hasValidValue($property, $propertySchema)) {
1,958✔
23
            return;
1,926✔
24
        }
25

26
        $property->addValidator(
795✔
27
            $this->getValidator($property, $propertySchema->getJson()[$this->key]),
795✔
28
        );
795✔
29
    }
30

31
    protected function hasValidValue(PropertyInterface $property, JsonSchema $propertySchema): bool
2,165✔
32
    {
33
        $json = $propertySchema->getJson();
2,165✔
34

35
        if (!isset($json[$this->key])) {
2,165✔
36
            return false;
2,160✔
37
        }
38

39
        if (!$this->isValueValid($json[$this->key])) {
811✔
NEW
40
            throw new SchemaException(
×
NEW
41
                sprintf(
×
NEW
42
                    "Invalid %s %s for property '%s' in file %s",
×
NEW
43
                    $this->key,
×
NEW
44
                    str_replace("\n", '', var_export($json[$this->key], true)),
×
NEW
45
                    $property->getName(),
×
NEW
46
                    $propertySchema->getFile(),
×
NEW
47
                ),
×
NEW
48
            );
×
49
        }
50

51
        return true;
811✔
52
    }
53

54
    abstract protected function isValueValid(mixed $value): bool;
55

56
    abstract protected function getValidator(PropertyInterface $property, mixed $value): PropertyValidatorInterface;
57
}
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