| Total Complexity | 11 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Coverage | 40.74% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class SessionObject { |
||
| 6 | protected $value; |
||
| 7 | protected $duration; |
||
| 8 | protected $creationTime; |
||
| 9 | |||
| 10 | 1 | public function __construct($value, $duration) { |
|
| 14 | 1 | } |
|
| 15 | |||
| 16 | /** |
||
| 17 | * |
||
| 18 | * @return mixed |
||
| 19 | */ |
||
| 20 | 1 | public function getValue() { |
|
| 21 | 1 | if (! $this->isExpired ()) |
|
| 22 | 1 | return $this->value; |
|
| 23 | 1 | return; |
|
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * |
||
| 28 | * @return mixed |
||
| 29 | */ |
||
| 30 | public function getDuration() { |
||
| 31 | return $this->duration; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * |
||
| 36 | * @return mixed |
||
| 37 | */ |
||
| 38 | public function getCreationTime() { |
||
| 39 | return $this->creationTime; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * |
||
| 44 | * @param mixed $value |
||
| 45 | */ |
||
| 46 | public function setValue($value) { |
||
| 47 | if ($value !== $this->value) |
||
| 48 | $this->creationTime = time (); |
||
| 49 | return $this->value = $value; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * |
||
| 54 | * @param mixed $duration |
||
| 55 | */ |
||
| 56 | public function setDuration($duration) { |
||
| 57 | $this->duration = $duration; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * |
||
| 62 | * @return boolean |
||
| 63 | */ |
||
| 64 | 1 | public function isExpired() { |
|
| 65 | 1 | return \time () - $this->creationTime > $this->duration; |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * |
||
| 70 | * @return number |
||
| 71 | */ |
||
| 72 | public function getTimeout() { |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 |