GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AnalyzerService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A analyze() 0 21 2
A process() 0 8 2
1
<?php
2
3
namespace Inspector\Application\Service;
4
5
use Inspector\Analysis\Analyzer;
6
use Inspector\Analysis\Result\AnalysisResult;
7
use Inspector\Filesystem\CodeScanner;
8
use Inspector\Analysis\Feedback\FeedbackInterface;
9
use Inspector\Foundation\AbstractService as Service;
10
11
/**
12
 * @author Kabir Baidhya
13
 */
14
class AnalyzerService extends Service
15
{
16
17
    /**
18
     * @var Analyzer
19
     */
20
    protected $analyzer;
21
22
    /**
23
     * @var CodeScanner
24
     */
25
    protected $scanner;
26
27
    /**
28
     * @var FeedbackInterface
29
     */
30
    protected $feedback;
31
32
    /**
33
     * @var ReportService
34
     */
35
    protected $reportService;
36
37
    /**
38
     * @param Analyzer $analyzer
39
     * @param CodeScanner $scanner
40
     * @param FeedbackInterface $feedback
41
     * @param ReportService $reportService
42
     */
43
    public function __construct(
44
        Analyzer $analyzer,
45
        CodeScanner $scanner,
46
        FeedbackInterface $feedback,
47
        ReportService $reportService
48
    ) {
49
        $this->analyzer = $analyzer;
50
        $this->scanner = $scanner;
51
        $this->feedback = $feedback;
52
        $this->reportService = $reportService;
53
    }
54
55
    /**
56
     * @param string $path
57
     * @param array $options
58
     * @return string
59
     */
60
    public function analyze($path, array $options)
61
    {
62
        $path = realpath($path);
63
        $source = $this->scanner->scan($path);
64
65
        $rawResult = $this->analyzer->analyze($source, $options);
66
        $result = $this->process($rawResult);
67
68
        if ($options['generate-report'] === true) {
69
            $reportPath = $options['path'];
70
            $report = $this->reportService->generateReport(compact('result', 'path'), $reportPath);
71
72
            return sprintf('<info>Report generated to</info> %s ', $report['path']);
73
        } else {
74
            $feedback = $this->feedback->generate($result, [
75
                'basePath' => $path
76
            ]);
77
78
            return $feedback;
79
        }
80
    }
81
82
    /**
83
     * Process raw analysis raw result
84
     *
85
     * @param array $rawResult
86
     * @return AnalysisResult
87
     */
88
    public function process(array $rawResult)
89
    {
90
        foreach ($rawResult as &$file) {
0 ignored issues
show
Unused Code introduced by
This foreach statement is empty and can be removed.

This check looks for foreach loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
91
//            $file->
92
        }
93
94
        return new AnalysisResult($rawResult);
95
    }
96
97
}
98