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

Comodojo/Foundation/Console/AbstractCommand.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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) {
45
46
        $me = get_called_class();
47
        $myself = new $me();
48
49
        return $myself->setConfiguration($configuration);
50
51
    }
52
53
}
54