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

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

11 Apr 2025 04:41PM UTC coverage: 98.813%. Remained the same
14407937636

Pull #88

github

web-flow
Merge 7dcf4b3f6 into 8823c7c14
Pull Request #88: Fix code typo in README

2914 of 2949 relevant lines covered (98.81%)

517.53 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 = [];
524✔
28
        $reference = $propertySchema->getJson()['$ref'];
524✔
29
        $dictionary = $this->schema->getSchemaDictionary();
524✔
30

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

34
            if ($definition) {
519✔
35
                if ($this->schema->getClassPath() !== $definition->getSchema()->getClassPath() ||
519✔
36
                    $this->schema->getClassName() !== $definition->getSchema()->getClassName() ||
519✔
37
                    (
38
                        $this->schema->getClassName() === 'ExternalSchema' &&
519✔
39
                        $definition->getSchema()->getClassName() === 'ExternalSchema'
519✔
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);
519✔
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