StandardNameToSniffsFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A isMatch() 0 5 1
A create() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\PHP7_CodeSniffer\Sniff\Factory;
9
10
use Symplify\PHP7_CodeSniffer\Contract\Sniff\Factory\SniffFactoryInterface;
11
use Symplify\PHP7_CodeSniffer\Standard\Finder\StandardFinder;
12
13
final class StandardNameToSniffsFactory implements SniffFactoryInterface
14
{
15
    /**
16
     * @var StandardFinder
17
     */
18
    private $standardFinder;
19
20
    /**
21
     * @var RulesetXmlToSniffsFactory
22
     */
23
    private $rulesetXmlToSniffsFactory;
24
25 11
    public function __construct(
26
        StandardFinder $standardFinder,
27
        RulesetXmlToSniffsFactory $rulesetXmlToSniffsFactory
28
    ) {
29 11
        $this->standardFinder = $standardFinder;
30 11
        $this->rulesetXmlToSniffsFactory = $rulesetXmlToSniffsFactory;
31 11
    }
32
33 9
    public function isMatch(string $reference) : bool
34
    {
35 9
        $standards = $this->standardFinder->getStandards();
36 9
        return (isset($standards[$reference]));
37
    }
38
39 7
    public function create(string $standardName) : array
40
    {
41 7
        $rulesetXml = $this->standardFinder->getRulesetPathForStandardName($standardName);
42 7
        return $this->rulesetXmlToSniffsFactory->create($rulesetXml);
43
    }
44
}
45