Failed Conditions
Pull Request — experimental/sf (#3240)
by Kentaro
71:31 queued 20:38
created

PaymentMethodPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
nc 3
nop 1
dl 16
loc 16
ccs 8
cts 10
cp 0.8
crap 3.072
rs 9.7333
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\DependencyInjection\Compiler;
15
16
use Eccube\Service\Payment\PaymentMethodInterface;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20 View Code Duplication
class PaymentMethodPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
introduced by
Missing class doc comment
Loading history...
21
{
22
    const PAYMENT_METHOD_TAG = 'eccube.payment.method';
23
24 1
    public function process(ContainerBuilder $container)
25
    {
26 1
        $ids = $container->findTaggedServiceIds(self::PAYMENT_METHOD_TAG);
27
28 1
        foreach ($ids as $id => $tags) {
29 1
            $def = $container->getDefinition($id);
30 1
            $def->setPublic(true);
31 1
            $class = $container->getParameterBag()->resolveValue($def->getClass());
32 1
            if (!is_subclass_of($class, PaymentMethodInterface::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Eccube\Service\Payment\...tMethodInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
33
                throw new \InvalidArgumentException(
34
                    sprintf('Service "%s" must implement interface "%s".', $id, PaymentMethodInterface::class));
35
            }
36
37 1
            $container->setParameter($class, $class);
38
        }
39
    }
40
}
41