Completed
Push — 4.0 ( 954171...ed2d0a )
by Marco
13:55
created

Timestamp::getTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Comodojo\Dispatcher\Components;
2
3
/**
4
 *
5
 * @package     Comodojo dispatcher
6
 * @author      Marco Giovinazzi <[email protected]>
7
 * @license     GPL-3.0+
8
 *
9
 * LICENSE:
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
 */
24
25
trait Timestamp {
26
27
    protected $timestamp = null;
28
29
    final public function getTimestamp() {
30
31
        return $this->timestamp;
32
33
    }
34
35
    final public function setTimestamp($time = null) {
36
37
        $this->timestamp = filter_var($time, FILTER_VALIDATE_FLOAT, array(
38
            'options' => array(
39
                'decimal' => '.',
40
                'default' => microtime(true)
41
            )
42
        ));
43
44
        return $this;
45
46
    }
47
48
}
49