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