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

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

19 Sep 2024 03:30PM UTC coverage: 98.855% (+0.007%) from 98.848%
10944162140

Pull #84

github

wol-soft
add typing test
Pull Request #84: Optional const

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

3023 of 3058 relevant lines covered (98.86%)

531.51 hits per line

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

95.0
/src/PropertyProcessor/Property/ReferenceProcessor.php
1
<?php
2

3
declare(strict_types = 1);
4

5
namespace PHPModelGenerator\PropertyProcessor\Property;
6

7
use Exception;
8
use PHPModelGenerator\Exception\SchemaException;
9
use PHPModelGenerator\Model\Property\PropertyInterface;
10
use PHPModelGenerator\Model\SchemaDefinition\JsonSchema;
11
use PHPModelGenerator\PropertyProcessor\Decorator\SchemaNamespaceTransferDecorator;
12

13
/**
14
 * Class ReferenceProcessor
15
 *
16
 * @package PHPModelGenerator\PropertyProcessor\Property
17
 */
18
class ReferenceProcessor extends AbstractTypedValueProcessor
19
{
20
    /**
21
     * @inheritdoc
22
     *
23
     * @throws SchemaException
24
     */
25
    public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
26
    {
27
        $path = [];
507✔
28
        $reference = $propertySchema->getJson()['$ref'];
507✔
29
        $dictionary = $this->schema->getSchemaDictionary();
507✔
30

31
        try {
32
            $definition = $dictionary->getDefinition($reference, $this->schemaProcessor, $path);
507✔
33

34
            if ($definition) {
502✔
35
                if ($this->schema->getClassPath() !== $definition->getSchema()->getClassPath() ||
502✔
36
                    $this->schema->getClassName() !== $definition->getSchema()->getClassName() ||
502✔
37
                    (
38
                        $this->schema->getClassName() === 'ExternalSchema' &&
502✔
39
                        $definition->getSchema()->getClassName() === 'ExternalSchema'
502✔
40
                    )
41
                ) {
42
                    $this->schema->addNamespaceTransferDecorator(
240✔
43
                        new SchemaNamespaceTransferDecorator($definition->getSchema()),
240✔
44
                    );
240✔
45
                }
46

47
                return $definition->resolveReference($propertyName, $path, $this->propertyMetaDataCollection);
502✔
48
            }
49
        } catch (Exception $exception) {
6✔
50
            throw new SchemaException(
6✔
51
                "Unresolved Reference $reference in file {$propertySchema->getFile()}",
6✔
52
                0,
6✔
53
                $exception,
6✔
54
            );
6✔
55
        }
56

57
        throw new SchemaException("Unresolved Reference $reference in file {$propertySchema->getFile()}");
×
58
    }
59
}
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