Resolve::performAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
ccs 3
cts 6
cp 0.5
crap 2.5
rs 10
1
<?php
2
3
namespace Swaggest\JsonCli;
4
5
6
use Swaggest\JsonDiff\Exception;
7
use Swaggest\JsonDiff\JsonPointer;
8
use Yaoi\Command\Definition;
9
use Yaoi\Command\Option;
10
11
class Resolve extends Base
12
{
13
    public $pointer;
14
    public $path;
15
16
    /**
17
     * @param Definition $definition
18
     * @param \stdClass|static $options
19
     */
20 1
    static function setUpDefinition(Definition $definition, $options)
21
    {
22 1
        $options->path = Option::create()->setType()->setIsUnnamed()
23 1
            ->setDescription('Path to JSON/YAML file');
24 1
        $options->pointer = Option::create()->setType()->setIsUnnamed()
25 1
            ->setDescription('JSON Pointer, example /key4/1/a');
26 1
    }
27
28 1
    /**
29
     * @throws ExitCode
30 1
     */
31
    public function performAction()
32 1
    {
33
        $jsonData = $this->readData($this->path);
34
        try {
35
            $this->out = JsonPointer::getByPointer($jsonData, $this->pointer);
36
        } catch (Exception $e) {
37 1
            $this->response->error($e->getMessage());
38 1
            throw new ExitCode('', 1);
39
        }
40
        $this->postPerform();
41
    }
42
43
}