Failed Conditions
Pull Request — experimental/sf (#3240)
by Kentaro
43:45
created

PaymentMethodPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 9
Ratio 64.29 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
nc 3
nop 1
dl 9
loc 14
ccs 7
cts 9
cp 0.7778
crap 3.0987
rs 9.7998
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
class PaymentMethodPass implements CompilerPassInterface
0 ignored issues
show
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 View Code Duplication
        foreach ($ids as $id => $tags) {
29 1
            $def = $container->getDefinition($id);
30 1
            $class = $container->getParameterBag()->resolveValue($def->getClass());
31 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...
32
                throw new \InvalidArgumentException(
33
                    sprintf('Service "%s" must implement interface "%s".', $id, PaymentMethodInterface::class));
34
            }
35 1
            $def->setPublic(true);
36
        }
37
    }
38
}
39