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

CourseControllerTrait::hasCourse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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