-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDiffInfo.php
53 lines (44 loc) · 1.61 KB
/
DiffInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Swaggest\JsonCli;
use Yaoi\Command;
class DiffInfo extends BaseDiff
{
public $withContents;
public $withPaths;
/**
* @param Command\Definition $definition
* @param \stdClass|static $options
*/
static function setUpDefinition(Command\Definition $definition, $options)
{
parent::setUpDefinition($definition, $options);
$options->withContents = Command\Option::create()->setDescription('Add content to output');
$options->withPaths = Command\Option::create()->setDescription('Add paths to output');
$definition->description = 'Show diff info for two JSON documents';
}
public function performAction()
{
$this->prePerform();
$this->out = array(
'addedCnt' => $this->diff->getAddedCnt(),
'modifiedCnt' => $this->diff->getAddedCnt(),
'removedCnt' => $this->diff->getRemovedCnt(),
);
if ($this->withPaths) {
$this->out = array_merge($this->out, array(
'addedPaths' => $this->diff->getAddedPaths(),
'modifiedPaths' => $this->diff->getModifiedPaths(),
'removedPaths' => $this->diff->getRemovedPaths(),
));
}
if ($this->withContents) {
$this->out = array_merge($this->out, array(
'added' => $this->diff->getAdded(),
'modifiedNew' => $this->diff->getModifiedNew(),
'modifiedOriginal' => $this->diff->getModifiedOriginal(),
'removed' => $this->diff->getRemoved(),
));
}
$this->postPerform();
}
}