Code Duplication    Length = 16-16 lines in 2 locations

src/Registry.php 2 locations

@@ 95-110 (lines=16) @@
92
     *
93
     * @throws UnsupportedVersionException if the version is not supported
94
     */
95
    public function getConstraintsForType($version, $type)
96
    {
97
        $cache = & $this->constraintsForTypeCache[$version.$type];
98
99
        if ($cache === null) {
100
            $cache = [];
101
102
            foreach ($this->getConstraints($version) as $constraint) {
103
                if ($constraint->supports($type)) {
104
                    $cache[] = $constraint;
105
                }
106
            }
107
        }
108
109
        return $cache;
110
    }
111
112
    /**
113
     * Returns whether a keyword is supported in a given JSON Schema version.
@@ 121-136 (lines=16) @@
118
     * @return bool
119
     *
120
     */
121
    public function hasKeyword($version, $keyword)
122
    {
123
        $cache = & $this->keywordsCache[$version];
124
125
        if ($cache === null) {
126
            $cache = [];
127
128
            foreach ($this->getConstraints($version) as $constraint) {
129
                foreach ($constraint->keywords() as $constraintKeyword) {
130
                    $cache[$constraintKeyword] = true;
131
                }
132
            }
133
        }
134
135
        return isset($cache[$keyword]);
136
    }
137
138
    /**
139
     * Loads the constraints associated with a given JSON Schema version.