Completed
Push — master ( 4035f4...400e5d )
by Daniel
02:15
created

Task::applyExitCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of the Commander project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Commander;
9
10
use Doctrine\ORM\EntityManagerInterface;
11
use GravityMedia\Commander\Entity\TaskEntity;
12
13
/**
14
 * Task class.
15
 *
16
 * @package GravityMedia\Commander
17
 */
18
class Task
19
{
20
    /**
21
     * The entity manager.
22
     *
23
     * @var EntityManagerInterface
24
     */
25
    protected $entityManager;
26
27
    /**
28
     * The entity.
29
     *
30
     * @var TaskEntity
31
     */
32
    protected $entity;
33
34
    /**
35
     * Create task object.
36
     *
37
     * @param EntityManagerInterface $entityManager
38
     * @param TaskEntity             $entity
39
     */
40
    public function __construct(EntityManagerInterface $entityManager, TaskEntity $entity)
41
    {
42
        $this->entityManager = $entityManager;
43
        $this->entity = $entity;
44
    }
45
46
    /**
47
     * Get entity
48
     *
49
     * @return TaskEntity
50
     */
51
    public function getEntity()
52
    {
53
        return $this->entity;
54
    }
55
56
    /**
57
     * Apply PID.
58
     *
59
     * @param int $pid
60
     *
61
     * @return $this
62
     */
63
    public function applyPid($pid)
64
    {
65
        $this->entity->setPid($pid);
66
        $this->entityManager->flush();
67
68
        return $this;
69
    }
70
71
    /**
72
     * Apply exit code.
73
     *
74
     * @param int $exitCode
75
     *
76
     * @return $this
77
     */
78
    public function applyExitCode($exitCode)
79
    {
80
        $this->entity->setExitCode($exitCode);
81
        $this->entityManager->flush();
82
83
        return $this;
84
    }
85
}
86