Passed
Push — main ( e5a85d...619edc )
by Michiel
07:04
created

PHPMDRendererRemoveFromCache::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
namespace Phing\Task\Ext\Analyzer\Phpmd;
22
23
use Phing\Util\DataStore;
24
use PHPMD\AbstractRenderer;
25
use PHPMD\Report;
26
27
/**
28
 * This class will remove files with violations from cache
29
 *
30
 * @category PHP
31
 * @package  PHPMD
32
 * @author   Rui Filipe Da Cunha Alves <[email protected]>
33
 */
34
class PHPMDRendererRemoveFromCache extends AbstractRenderer
35
{
36
    /**
37
     * Cache data storage
38
     *
39
     * @var DataStore
40
     */
41
    protected $cache;
42
43
    /**
44
     * Constructor
45
     *
46
     * @param DataStore $cache
47
     */
48
    public function __construct($cache)
49
    {
50
        $this->cache = $cache;
51
    }
52
53
    /**
54
     * This method will be called when the engine has finished the source
55
     * analysis phase. To remove file with violations from cache.
56
     *
57
     * @param  Report $report
58
     * @return void
59
     */
60
    public function renderReport(Report $report)
61
    {
62
        foreach ($report->getRuleViolations() as $violation) {
63
            $fileName = $violation->getFileName();
64
            $this->cache->remove($fileName, null);
65
        }
66
    }
67
}
68