1 | <?php |
||
32 | class LsTreeCommand extends BaseCommand |
||
33 | { |
||
34 | const LS_TREE_COMMAND = 'ls-tree'; |
||
35 | |||
36 | /** |
||
37 | * constructor |
||
38 | * |
||
39 | * @param \GitElephant\Repository $repo The repository object this command |
||
40 | * will interact with |
||
41 | */ |
||
42 | 15 | public function __construct(Repository $repo = null) |
|
46 | |||
47 | /** |
||
48 | * build a ls-tree command |
||
49 | * |
||
50 | * @param string|Branch $ref The reference to build the tree from |
||
51 | * |
||
52 | * @throws \RuntimeException |
||
53 | * @return string |
||
54 | */ |
||
55 | 1 | public function fullTree($ref = 'HEAD') |
|
72 | |||
73 | /** |
||
74 | * tree of a given path |
||
75 | * |
||
76 | * @param string $ref reference |
||
77 | * @param string|NodeObject $path path |
||
78 | * |
||
79 | * @throws \RuntimeException |
||
80 | * @return string |
||
81 | */ |
||
82 | 15 | public function tree($ref = 'HEAD', $path = null) |
|
83 | { |
||
84 | 15 | if ($path instanceof NodeObject) { |
|
85 | 9 | $subjectPath = $path->getFullPath() . ($path->isTree() ? '/' : ''); |
|
86 | } |
||
87 | else { |
||
88 | 15 | $subjectPath = $path; |
|
89 | } |
||
90 | |||
91 | 15 | $what = $ref; |
|
92 | 15 | if ($ref instanceof TreeishInterface) { |
|
93 | 1 | $what = $ref->getSha(); |
|
94 | } |
||
95 | 15 | $this->clearAll(); |
|
96 | 15 | $this->addCommandName(self::LS_TREE_COMMAND); |
|
97 | 15 | $this->addCommandArgument('-l'); |
|
98 | 15 | $subject = $what; |
|
99 | 15 | $this->addCommandSubject($subject); |
|
100 | 15 | $this->addPath($subjectPath); |
|
101 | |||
102 | 15 | return $this->getCommand(); |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * build ls-tree command that list all |
||
107 | * |
||
108 | * @param null|string $ref the reference to build the tree from |
||
109 | * |
||
110 | * @throws \RuntimeException |
||
111 | * @return string |
||
112 | */ |
||
113 | 1 | public function listAll($ref = null) |
|
125 | } |
||
126 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.