Completed
Push — master ( 466032...5da320 )
by Marco
02:49
created

AbstractCommand::setStartTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php namespace Comodojo\Foundation\Console;
2
3
use \Comodojo\Foundation\Base\Configuration;
4
use \Comodojo\Foundation\Base\ConfigurationTrait;
5
use \Symfony\Component\Console\Command\Command;
6
use \Comodojo\Foundation\Logging\LoggerTrait;
7
use \DateTime;
8
9
/**
10
 * @package     Comodojo Foundation
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @license     MIT
13
 *
14
 * LICENSE:
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 */
24
25
abstract class AbstractCommand extends Command {
26
27
    use ConfigurationTrait;
28
    use LoggerTrait;
29
30
    /**
31
     * @var DateTime
32
     */
33
    protected $start_time;
34
35
    public function setStartTime() {
36
        $this->start_time = microtime(true);
0 ignored issues
show
Documentation Bug introduced by
It seems like microtime(true) of type double is incompatible with the declared type object<DateTime> of property $start_time.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
    }
38
39
    public function getEndTime() {
40
        $time = microtime(true);
41
        return $time - $this->start_time;
42
    }
43
44
    static public function init(Configuration $configuration) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
45
46
        $me = get_called_class();
47
        $myself = new $me();
48
49
        return $myself->setConfiguration($configuration);
50
51
    }
52
53
}
54