Skip to content

Commit f6a16e2

Browse files
committed
added constant for analyzer context
1 parent 7d7a760 commit f6a16e2

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

src/Analyzer/EtSchemaAnalyzer.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
*/
1919
class EtSchemaAnalyzer implements AnalyzerInterface
2020
{
21+
22+
/**
23+
* Analyser context
24+
*/
25+
const CONTEXT = 'etSchema';
26+
27+
/**
28+
* @var array of actions
29+
*/
2130
private static $actions = [
2231
'addedRecord' => [
2332
'level' => Level::MINOR,
@@ -46,11 +55,6 @@ class EtSchemaAnalyzer implements AnalyzerInterface
4655
]
4756
];
4857

49-
/**
50-
* @var string
51-
*/
52-
private $context = 'etSchema';
53-
5458
/**
5559
* @var Report
5660
*/
@@ -304,7 +308,7 @@ public function reportChanges(array $changes): void
304308
{
305309
foreach ($changes as $change) {
306310
$this->report->add(
307-
$this->context,
311+
self::CONTEXT,
308312
new EtSchemaOperation(
309313
$change['location'],
310314
$change['code'],
@@ -327,16 +331,16 @@ public function analyze($registryBefore, $registryAfter)
327331
{
328332
$changes = [];
329333
$commonModules = array_intersect(
330-
array_keys($registryBefore->data['etSchema']),
331-
array_keys($registryAfter->data['etSchema'])
334+
array_keys($registryBefore->data[self::CONTEXT]),
335+
array_keys($registryAfter->data[self::CONTEXT])
332336
);
333337
foreach ($commonModules as $moduleName) {
334338
$changes = array_merge(
335339
$changes,
336340
$this->analyzeModuleConfig(
337341
$moduleName,
338-
$registryBefore->data['etSchema'][$moduleName],
339-
$registryAfter->data['etSchema'][$moduleName]
342+
$registryBefore->data[self::CONTEXT][$moduleName],
343+
$registryAfter->data[self::CONTEXT][$moduleName]
340344
)
341345
);
342346
}
@@ -345,11 +349,11 @@ public function analyze($registryBefore, $registryAfter)
345349
$changes,
346350
$this->removedModuleConfig(
347351
array_intersect_key(
348-
$registryBefore->data['etSchema'],
352+
$registryBefore->data[self::CONTEXT],
349353
array_flip(
350354
array_diff(
351-
array_keys($registryBefore->data['etSchema']),
352-
array_keys($registryAfter->data['etSchema'])
355+
array_keys($registryBefore->data[self::CONTEXT]),
356+
array_keys($registryAfter->data[self::CONTEXT])
353357
)
354358
)
355359
)
@@ -360,11 +364,11 @@ public function analyze($registryBefore, $registryAfter)
360364
$changes,
361365
$this->addedModuleConfig(
362366
array_intersect_key(
363-
$registryAfter->data['etSchema'],
367+
$registryAfter->data[self::CONTEXT],
364368
array_flip(
365369
array_diff(
366-
array_keys($registryAfter->data['etSchema']),
367-
array_keys($registryBefore->data['etSchema'])
370+
array_keys($registryAfter->data[self::CONTEXT]),
371+
array_keys($registryBefore->data[self::CONTEXT])
368372
)
369373
)
370374
)
@@ -375,4 +379,4 @@ public function analyze($registryBefore, $registryAfter)
375379
$this->reportChanges($changes);
376380
return $this->report;
377381
}
378-
}
382+
}

src/DbSchemaReport.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use PHPSemVerChecker\Report\Report as ReportAlias;
1010
use PHPSemVerChecker\SemanticVersioning\Level;
11+
use Magento\SemanticVersionChecker\Analyzer\EtSchemaAnalyzer;
1112

1213
class DbSchemaReport extends ReportAlias
1314
{
@@ -24,6 +25,6 @@ public function __construct()
2425
$this->differences['system'] = $levels;
2526
$this->differences['xsd'] = $levels;
2627
$this->differences['less'] = $levels;
27-
$this->differences['etSchema'] = $levels;
28+
$this->differences[EtSchemaAnalyzer::CONTEXT] = $levels;
2829
}
2930
}

src/DbSchemaReporter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\SemanticVersionChecker\Reporter\TableReporter;
1010
use Symfony\Component\Console\Output\OutputInterface;
11+
use Magento\SemanticVersionChecker\Analyzer\EtSchemaAnalyzer;
1112

1213
/**
1314
* Class DbSchemaReporter
@@ -30,6 +31,6 @@ public function output(OutputInterface $output)
3031
$this->outputReport($output, $this->report, 'system');
3132
$this->outputReport($output, $this->report, 'xsd');
3233
$this->outputReport($output, $this->report, 'less');
33-
$this->outputReport($output, $this->report, 'etSchema');
34+
$this->outputReport($output, $this->report, EtSchemaAnalyzer::CONTEXT);
3435
}
3536
}

src/ReportTypes.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Magento\SemanticVersionChecker;
1111

12+
use Magento\SemanticVersionChecker\Analyzer\EtSchemaAnalyzer;
1213
/**
1314
* Holds the different report type keys.
1415
*/
@@ -22,5 +23,5 @@ class ReportTypes
2223
public const SYSTEM_XML = 'systemXml';
2324
public const XSD = 'xsd';
2425
public const LESS = 'less';
25-
public const ET_SCHEMA = 'etSchema';
26+
public const ET_SCHEMA = EtSchemaAnalyzer::CONTEXT;
2627
}

src/Reporter/HtmlDbSchemaReporter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PHPSemVerChecker\SemanticVersioning\Level;
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
17-
17+
use Magento\SemanticVersionChecker\Analyzer\EtSchemaAnalyzer;
1818
/**
1919
* @package Magento\SemanticVersionChecker
2020
*/
@@ -61,7 +61,7 @@ public function output(OutputInterface $output)
6161
'system',
6262
'xsd',
6363
'less',
64-
'etSchema'
64+
EtSchemaAnalyzer::CONTEXT
6565
];
6666

6767
foreach ($contexts as $context) {

src/Scanner/EtSchemaScanner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\SemanticVersionChecker\Registry\XmlRegistry;
1111
use Magento\SemanticVersionChecker\Scanner\EtSchema\XmlConverter;
1212
use PHPSemVerChecker\Registry\Registry;
13+
use Magento\SemanticVersionChecker\Analyzer\EtSchemaAnalyzer;
1314

1415
/**
1516
* Class EtSchemaScanner
@@ -57,7 +58,7 @@ public function scan(string $file): void
5758
$doc->loadXML(file_get_contents($file));
5859
$moduleName = $this->getModuleNameByPath->resolveByEtcDirFilePath($file);
5960
$data = $this->converter->convert($doc);
60-
$this->getRegistry()->data['etSchema'][$moduleName] = $data;
61+
$this->getRegistry()->data[EtSchemaAnalyzer::CONTEXT][$moduleName] = $data;
6162
}
6263

6364
/**

0 commit comments

Comments
 (0)