YamlUriRetriever   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 22
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadSchema() 0 14 2
1
<?php
2
namespace ElevenLabs\Api\JsonSchema\Uri;
3
4
use JsonSchema\Uri\UriRetriever;
5
use Symfony\Component\Yaml\Yaml;
6
7
/**
8
 * Load Schema From a YAML file
9
 */
10
class YamlUriRetriever extends UriRetriever
11
{
12
    /**
13
     * @var array|object[]
14
     * @see loadSchema
15
     */
16
    private $schemaCache = array();
17
18 2
    protected function loadSchema($fetchUri)
19
    {
20 2
        if (isset($this->schemaCache[$fetchUri])) {
21
            return $this->schemaCache[$fetchUri];
22
        }
23
24 2
        $contents = $this->getUriRetriever()->retrieve($fetchUri);
25
26 2
        $contents = Yaml::parse($contents);
27 2
        $jsonSchema = json_decode(json_encode($contents));
28
29 2
        $this->schemaCache[$fetchUri] = $jsonSchema;
30
31 2
        return $jsonSchema;
32
    }
33
}
34