Completed
Push — master ( fc1588...7621d0 )
by Julito
16:55
created

CourseControllerTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 48
rs 10
c 1
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setCourse() 0 3 1
A setSession() 0 3 1
A getCourse() 0 3 1
A getSession() 0 3 1
A getSessionId() 0 3 2
A hasCourse() 0 3 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Controller;
5
6
use Chamilo\CoreBundle\Entity\Course;
7
use Chamilo\CoreBundle\Entity\Session;
8
9
/**
10
 * Trait CourseControllerTrait.
11
 * Implements the functions defined by the CourseControllerInterface.
12
 */
13
trait CourseControllerTrait
14
{
15
    protected $course;
16
    protected $session;
17
18
    /**
19
     * @return mixed
20
     */
21
    public function setCourse(Course $course)
22
    {
23
        $this->course = $course;
24
    }
25
26
    /**
27
     * @return Course
28
     */
29
    public function getCourse()
30
    {
31
        return $this->course;
32
    }
33
34
    public function hasCourse(): bool
35
    {
36
        return null !== $this->course;
37
    }
38
39
    /**
40
     * @return Session
41
     */
42
    public function getSession()
43
    {
44
        return $this->session;
45
    }
46
47
    /**
48
     * @return mixed
49
     */
50
    public function setSession(Session $session)
51
    {
52
        $this->session = $session;
53
    }
54
55
    /**
56
     * @return int
57
     */
58
    public function getSessionId()
59
    {
60
        return $this->session ? $this->getSession()->getId() : 0;
61
    }
62
}
63