1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Code-Insight library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/code-insight |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\CodeInsight\KnowledgeBase\DataCollector; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use Aura\Sql\ExtendedPdoInterface; |
15
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBase; |
16
|
|
|
use Go\ParserReflection\ReflectionFileNamespace; |
17
|
|
|
|
18
|
|
|
abstract class AbstractDataCollector |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Database. |
23
|
|
|
* |
24
|
|
|
* @var ExtendedPdoInterface |
25
|
|
|
*/ |
26
|
|
|
protected $db; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Creates data collector instance. |
30
|
|
|
* |
31
|
|
|
* @param ExtendedPdoInterface $db Database. |
32
|
|
|
*/ |
33
|
22 |
|
public function __construct(ExtendedPdoInterface $db) |
|
|
|
|
34
|
|
|
{ |
35
|
22 |
|
$this->db = $db; |
36
|
22 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Collect data from a namespace. |
40
|
|
|
* |
41
|
|
|
* @param integer $file_id File id. |
42
|
|
|
* @param ReflectionFileNamespace $namespace Namespace. |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
abstract public function collectData($file_id, ReflectionFileNamespace $namespace); |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Aggregate previously collected data. |
50
|
|
|
* |
51
|
|
|
* @param KnowledgeBase $knowledge_base Knowledge base. |
52
|
|
|
* |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
4 |
|
public function aggregateData(KnowledgeBase $knowledge_base) |
56
|
|
|
{ |
57
|
|
|
|
58
|
4 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Delete previously collected data for a files. |
62
|
|
|
* |
63
|
|
|
* @param array $file_ids File IDs. |
64
|
|
|
* |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
abstract public function deleteData(array $file_ids); |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Returns statistics about the code. |
71
|
|
|
* |
72
|
|
|
* @return array |
73
|
|
|
*/ |
74
|
|
|
public function getStatistics() |
75
|
|
|
{ |
76
|
|
|
return array(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.