Journal::getJournalMoves()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Entity\Accounting;
12
13
use App\Entity\EntityInterface;
14
use App\Entity\Traits;
15
use App\Enum\Entity\JournalTypeEnum;
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\ORM\Mapping as ORM;
18
use PascalDeVink\ShortUuid\ShortUuid;
19
use Symfony\Component\Validator\Constraints as Assert;
20
21
/**
22
 * @ORM\Entity()
23
 * @ORM\Table(name="accounting_journals")
24
 */
25
class Journal implements EntityInterface
26
{
27
    use Traits\PropertyIdGeneratedTrait;
28
29
    //-------------------------------------------------------------------------------------------
30
31
    /**
32
     * @var string
33
     * @ORM\Column(name="type", type="string", length=50, nullable=false)
34
     *
35
     * @Assert\NotBlank()
36
     * @Assert\Choice(callback={"App\Enum\Entity\JournalTypeEnum", "toArray"})
37
     * @Assert\Length(min="1", max="50")
38
     */
39
    private $type;
40
41
    //-------------------------------------------------------------------------------------------
42
    /**
43
     * @var ArrayCollection|JournalMove[]
44
     * @ORM\OneToMany(targetEntity="App\Entity\Accounting\JournalMove", mappedBy="journal")
45
     */
46
    private $journalMoves;
47
48
    /**
49
     * @var Task
50
     * @ORM\ManyToOne(targetEntity="App\Entity\Accounting\Task", inversedBy="journals")
51
     * @ORM\JoinColumn(name="journal_id", referencedColumnName="id", nullable=false)
52
     *
53
     * @Assert\NotNull()
54
     */
55
    private $task;
56
57
    //-------------------------------------------------------------------------------------------
58
59
    public function __construct(Task $task, JournalTypeEnum $type)
60
    {
61
        $this->id = ShortUuid::uuid4();
62
        $this->type = $type->getValue();
63
        $this->task = $task;
64
        $this->journalMoves = new ArrayCollection();
65
    }
66
67
    //-------------------------------------------------------------------------------------------
68
69
    public function getType(): JournalTypeEnum
70
    {
71
        return new JournalTypeEnum($this->type);
72
    }
73
74
    public function getTask(): Task
75
    {
76
        return $this->task;
77
    }
78
79
    /**
80
     * @return JournalMove[]|ArrayCollection
81
     */
82
    public function getJournalMoves(): ArrayCollection
83
    {
84
        return $this->journalMoves;
85
    }
86
}
87