Passed
Push — main ( f0ecf6...ccc364 )
by Karl
25:43
created

Journal::getJournalEntries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Entity;
4
5
use ApiPlatform\Metadata\ApiResource;
6
use App\Repository\JournalRepository;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\DBAL\Types\Types;
10
use Doctrine\ORM\Mapping as ORM;
11
12
#[ORM\Entity(repositoryClass: JournalRepository::class)]
13
#[ApiResource]
14
class Journal
15
{
16
    #[ORM\Id]
17
    #[ORM\GeneratedValue]
18
    #[ORM\Column]
19
    private ?int $id = null;
20
21
    #[ORM\Column(type: Types::DATE_MUTABLE)]
22
    private ?\DateTimeInterface $FirstDay = null;
23
24
    #[ORM\Column(type: Types::DATE_MUTABLE)]
25
    private ?\DateTimeInterface $LastDay = null;
26
27
    #[ORM\Column(length: 255, nullable: true)]
28
    private ?string $ChartOfAccount = null;
29
30
    /**
31
     * @var Collection<int, JournalEntry>
32
     */
33
    #[ORM\OneToMany(targetEntity: JournalEntry::class, mappedBy: 'Journal', orphanRemoval: true)]
34
    private Collection $journalEntries;
35
36
    /**
37
     * @var Collection<int, Organization>
38
     */
39
    #[ORM\OneToMany(targetEntity: Organization::class, mappedBy: 'journal')]
40
    private Collection $organization;
41
42
    public function __construct()
43
    {
44
        $this->journalEntries = new ArrayCollection();
45
        $this->organization = new ArrayCollection();
46
    }
47
48
    public function getId(): ?int
49
    {
50
        return $this->id;
51
    }
52
53
    public function getFirstDay(): ?\DateTimeInterface
54
    {
55
        return $this->FirstDay;
56
    }
57
58
    public function setFirstDay(\DateTimeInterface $FirstDay): static
59
    {
60
        $this->FirstDay = $FirstDay;
61
62
        return $this;
63
    }
64
65
    public function getLastDay(): ?\DateTimeInterface
66
    {
67
        return $this->LastDay;
68
    }
69
70
    public function setLastDay(\DateTimeInterface $LastDay): static
71
    {
72
        $this->LastDay = $LastDay;
73
74
        return $this;
75
    }
76
77
    public function getChartOfAccount(): ?string
78
    {
79
        return $this->ChartOfAccount;
80
    }
81
82
    public function setChartOfAccount(?string $ChartOfAccount): static
83
    {
84
        $this->ChartOfAccount = $ChartOfAccount;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @return Collection<int, JournalEntry>
91
     */
92
    public function getJournalEntries(): Collection
93
    {
94
        return $this->journalEntries;
95
    }
96
97
    public function addJournalEntry(JournalEntry $journalEntry): static
98
    {
99
        if (!$this->journalEntries->contains($journalEntry)) {
100
            $this->journalEntries->add($journalEntry);
101
            $journalEntry->setJournal($this);
102
        }
103
104
        return $this;
105
    }
106
107
    public function removeJournalEntry(JournalEntry $journalEntry): static
108
    {
109
        if ($this->journalEntries->removeElement($journalEntry)) {
110
            // set the owning side to null (unless already changed)
111
            if ($journalEntry->getJournal() === $this) {
112
                $journalEntry->setJournal(null);
113
            }
114
        }
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return Collection<int, Organization>
121
     */
122
    public function getOrganization(): Collection
123
    {
124
        return $this->organization;
125
    }
126
127
    public function addOrganization(Organization $organization): static
128
    {
129
        if (!$this->organization->contains($organization)) {
130
            $this->organization->add($organization);
131
            $organization->setJournal($this);
132
        }
133
134
        return $this;
135
    }
136
137
    public function removeOrganization(Organization $organization): static
138
    {
139
        if ($this->organization->removeElement($organization)) {
140
            // set the owning side to null (unless already changed)
141
            if ($organization->getJournal() === $this) {
142
                $organization->setJournal(null);
143
            }
144
        }
145
146
        return $this;
147
    }
148
}
149