LogActivity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDuration() 0 10 3
1
<?php
2
3
namespace Cothema\Model\User;
4
5
use \Doctrine\ORM\Mapping as ORM;
6
use \Kdyby\Doctrine\Entities;
7
8
/**
9
 * @ORM\Entity
10
 * @ORM\Table(name="log_activity")
11
 */
12
class LogActivity extends Entities\BaseEntity
13
{
14
15
    use Entities\Attributes\Identifier;
16
17
    /**
18
     * @ORM\ManyToOne(targetEntity="User")
19
     * @ORM\JoinColumn(name="user", referencedColumnName="id")
20
     */
21
    public $user;
22
23
    /**
24
     * @ORM\Column(name="time_from", type="datetime")
25
     */
26
    public $timeFrom;
27
28
    /**
29
     * @ORM\Column(name="time_to", type="datetime")
30
     */
31
    public $timeTo;
32
33
    public function getDuration()
34
    {
35
        if (isset($this->timeFrom) && isset($this->timeTo)) {
36
            $diff = $this->timeFrom->diff($this->timeTo);
37
38
            return $diff->format('%h:%I:%S');
39
        }
40
41
        return null;
42
    }
43
}
44