Code Duplication    Length = 17-17 lines in 2 locations

src/Core/Variables/VariableExtractor.php 1 location

@@ 178-194 (lines=17) @@
175
     * @param string $accessor
176
     * @return mixed
177
     */
178
    protected function extractWithAccessor($subject, $propertyName, $accessor)
179
    {
180
        if ($accessor === self::ACCESSOR_ARRAY && is_array($subject) && array_key_exists($propertyName, $subject)
181
            || $subject instanceof \ArrayAccess && $subject->offsetExists($propertyName)
182
        ) {
183
            return $subject[$propertyName];
184
        } elseif (is_object($subject)) {
185
            if ($accessor === self::ACCESSOR_GETTER) {
186
                return call_user_func_array([$subject, 'get' . ucfirst($propertyName)], []);
187
            } elseif ($accessor === self::ACCESSOR_ASSERTER) {
188
                return $this->extractThroughAsserter($subject, $propertyName);
189
            } elseif ($accessor === self::ACCESSOR_PUBLICPROPERTY && property_exists($subject, $propertyName)) {
190
                return $subject->$propertyName;
191
            }
192
        }
193
        return null;
194
    }
195
196
    /**
197
     * Detect which type of accessor to use when extracting

src/Core/Variables/StandardVariableProvider.php 1 location

@@ 326-342 (lines=17) @@
323
     * @param string $accessor
324
     * @return mixed
325
     */
326
    protected function extractWithAccessor($subject, $propertyName, $accessor)
327
    {
328
        if ($accessor === self::ACCESSOR_ARRAY && is_array($subject) && array_key_exists($propertyName, $subject)
329
            || $subject instanceof \ArrayAccess && $subject->offsetExists($propertyName)
330
        ) {
331
            return $subject[$propertyName];
332
        } elseif (is_object($subject)) {
333
            if ($accessor === self::ACCESSOR_GETTER) {
334
                return call_user_func_array([$subject, 'get' . ucfirst($propertyName)], []);
335
            } elseif ($accessor === self::ACCESSOR_ASSERTER) {
336
                return $this->extractThroughAsserter($subject, $propertyName);
337
            } elseif ($accessor === self::ACCESSOR_PUBLICPROPERTY && property_exists($subject, $propertyName)) {
338
                return $subject->$propertyName;
339
            }
340
        }
341
        return null;
342
    }
343
344
    /**
345
     * Detect which type of accessor to use when extracting