Debug::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Compiler\Pass;
17
18
use phpDocumentor\Compiler\CompilerPassInterface;
19
use phpDocumentor\Descriptor\ProjectAnalyzer;
20
use phpDocumentor\Descriptor\ProjectDescriptor;
21
use Psr\Log\LoggerInterface;
22
23
/**
24
 * This class is responsible for sending statistical information to the log.
25
 *
26
 * For debugging purposes it can be convenient to send statistical information about the
27
 * ProjectDescriptor to the log of phpDocumentor.
28
 */
29
class Debug implements CompilerPassInterface
30
{
31
    const COMPILER_PRIORITY = 1000;
32
33
    /** @var LoggerInterface $log the logger to write the debug results to */
34
    protected $log;
35
36
    /** @var ProjectAnalyzer $analyzer service that compiles a summary of the project */
37
    protected $analyzer;
38
39
    /**
40
     * Registers the logger with this Compiler Pass.
41
     */
42 1
    public function __construct(LoggerInterface $log, ProjectAnalyzer $analyzer)
43
    {
44 1
        $this->log = $log;
45 1
        $this->analyzer = $analyzer;
46 1
    }
47
48 1
    public function getDescription(): string
49
    {
50 1
        return 'Analyze results and write report to log';
51
    }
52
53 1
    public function execute(ProjectDescriptor $project): void
54
    {
55 1
        $this->analyzer->analyze($project);
56 1
        $this->log->debug((string) $this->analyzer);
57 1
    }
58
}
59