Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
10 / 10
CRAP
100.00% covered (success)
100.00%
1 / 1
Command
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
10 / 10
11
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 setName
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setParams
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setHelp
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getHelp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasHelp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Console;
15
16/**
17 * Console command  class
18 *
19 * @category   Pop
20 * @package    Pop\Console
21 * @author     Nick Sagona, III <dev@nolainteractive.com>
22 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
23 * @license    http://www.popphp.org/license     New BSD License
24 * @version    3.2.0
25 */
26class Command
27{
28
29    /**
30     * Command name
31     * @var string
32     */
33    protected $name = null;
34
35    /**
36     * Command params
37     * @var string
38     */
39    protected $params = null;
40
41    /**
42     * Command help
43     * @var string
44     */
45    protected $help = null;
46
47    /**
48     * Instantiate the command object
49     *
50     * @param  string $name
51     * @param  string $params
52     * @param  string $help
53     * @return Command
54     */
55    public function __construct($name, $params = null, $help = null)
56    {
57        $this->name   = $name;
58        $this->params = $params;
59        $this->help   = $help;
60        return $this;
61    }
62
63    /**
64     * Set the command name
65     *
66     * @param  string $name
67     * @return Command
68     */
69    public function setName($name)
70    {
71        $this->name = $name;
72        return $this;
73    }
74
75    /**
76     * Set the command params
77     *
78     * @param  string $params
79     * @return Command
80     */
81    public function setParams($params)
82    {
83        $this->params = $params;
84        return $this;
85    }
86
87    /**
88     * Set the command help
89     *
90     * @param  string $help
91     * @return Command
92     */
93    public function setHelp($help)
94    {
95        $this->help = $help;
96        return $this;
97    }
98
99    /**
100     * Get the command name
101     *
102     * @return string
103     */
104    public function getName()
105    {
106        return $this->name;
107    }
108
109    /**
110     * Get the command params
111     *
112     * @return string
113     */
114    public function getParams()
115    {
116        return $this->params;
117    }
118
119    /**
120     * Determine if the command has params
121     *
122     * @return boolean
123     */
124    public function hasParams()
125    {
126        return (null !== $this->params);
127    }
128
129    /**
130     * Get the command help
131     *
132     * @return string
133     */
134    public function getHelp()
135    {
136        return $this->help;
137    }
138
139    /**
140     * Determine if the command has help
141     *
142     * @return boolean
143     */
144    public function hasHelp()
145    {
146        return (null !== $this->help);
147    }
148
149    /**
150     * Return the command name as string
151     *
152     * @return string
153     */
154    public function __toString()
155    {
156        return $this->name . ((null !== $this->params) ? ' ' . $this->params : null);
157    }
158
159}