Code Duplication    Length = 32-34 lines in 2 locations

lib/Drupal/Core/DependencyInjection/YamlFileLoader.php 1 location

@@ 340-373 (lines=34) @@
337
     *
338
     * @return array|string|Reference
339
     */
340
    private function resolveServices($value)
341
    {
342
        if (is_array($value)) {
343
            $value = array_map(array($this, 'resolveServices'), $value);
344
        } elseif (is_string($value) &&  0 === strpos($value, '@=')) {
345
            // Not supported.
346
            //return new Expression(substr($value, 2));
347
            throw new InvalidArgumentException(sprintf("'%s' is an Expression, but expressions are not supported.", $value));
348
        } elseif (is_string($value) &&  0 === strpos($value, '@')) {
349
            if (0 === strpos($value, '@@')) {
350
                $value = substr($value, 1);
351
                $invalidBehavior = null;
352
            } elseif (0 === strpos($value, '@?')) {
353
                $value = substr($value, 2);
354
                $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
355
            } else {
356
                $value = substr($value, 1);
357
                $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
358
            }
359
360
            if ('=' === substr($value, -1)) {
361
                $value = substr($value, 0, -1);
362
                $strict = false;
363
            } else {
364
                $strict = true;
365
            }
366
367
            if (null !== $invalidBehavior) {
368
                $value = new Reference($value, $invalidBehavior, $strict);
369
            }
370
        }
371
372
        return $value;
373
    }
374
375
}
376

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php 1 location

@@ 369-400 (lines=32) @@
366
     *
367
     * @return array|string|Reference
368
     */
369
    private function resolveServices($value)
370
    {
371
        if (is_array($value)) {
372
            $value = array_map(array($this, 'resolveServices'), $value);
373
        } elseif (is_string($value) &&  0 === strpos($value, '@=')) {
374
            return new Expression(substr($value, 2));
375
        } elseif (is_string($value) &&  0 === strpos($value, '@')) {
376
            if (0 === strpos($value, '@@')) {
377
                $value = substr($value, 1);
378
                $invalidBehavior = null;
379
            } elseif (0 === strpos($value, '@?')) {
380
                $value = substr($value, 2);
381
                $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
382
            } else {
383
                $value = substr($value, 1);
384
                $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
385
            }
386
387
            if ('=' === substr($value, -1)) {
388
                $value = substr($value, 0, -1);
389
                $strict = false;
390
            } else {
391
                $strict = true;
392
            }
393
394
            if (null !== $invalidBehavior) {
395
                $value = new Reference($value, $invalidBehavior, $strict);
396
            }
397
        }
398
399
        return $value;
400
    }
401
402
    /**
403
     * Loads from Extensions.