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
|
|
use PHPMD\AbstractRenderer;
|
22
|
|
use PHPMD\Report;
|
23
|
|
|
24
|
|
/**
|
25
|
|
* This class will remove files with violations from cache
|
26
|
|
*
|
27
|
|
* @category PHP
|
28
|
|
* @package PHPMD
|
29
|
|
* @author Rui Filipe Da Cunha Alves <ruifil@ruifil.com>
|
30
|
|
*/
|
31
|
|
class PHPMDRendererRemoveFromCache extends AbstractRenderer
|
32
|
|
{
|
33
|
|
/**
|
34
|
|
* Cache data storage
|
35
|
|
*
|
36
|
|
* @var DataStore
|
37
|
|
*/
|
38
|
|
protected $cache;
|
39
|
|
|
40
|
|
/**
|
41
|
|
* Constructor
|
42
|
|
*
|
43
|
|
* @param DataStore $cache
|
44
|
|
*/
|
45
|
0
|
public function __construct($cache)
|
46
|
|
{
|
47
|
0
|
$this->cache = $cache;
|
48
|
|
}
|
49
|
|
|
50
|
|
/**
|
51
|
|
* This method will be called when the engine has finished the source
|
52
|
|
* analysis phase. To remove file with violations from cache.
|
53
|
|
*
|
54
|
|
* @param Report $report
|
55
|
|
* @return void
|
56
|
|
*/
|
57
|
0
|
public function renderReport(Report $report)
|
58
|
|
{
|
59
|
0
|
foreach ($report->getRuleViolations() as $violation) {
|
60
|
0
|
$fileName = $violation->getFileName();
|
61
|
0
|
$this->cache->remove($fileName, null);
|
62
|
|
}
|
63
|
|
}
|
64
|
|
}
|