Passed
Push — main ( f1aa52...bbae52 )
by Karl
06:11
created

Journal   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 14
eloc 35
c 1
b 0
f 1
dl 0
loc 98
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setFirstDay() 0 5 1
A __construct() 0 3 1
A getId() 0 3 1
A getJournalEntries() 0 3 1
A getChartOfAccount() 0 3 1
A setChartOfAccount() 0 5 1
A addJournalEntry() 0 8 2
A getLastDay() 0 3 1
A removeJournalEntry() 0 10 3
A getFirstDay() 0 3 1
A setLastDay() 0 5 1
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
    public function __construct()
37
    {
38
        $this->journalEntries = new ArrayCollection();
39
    }
40
41
    public function getId(): ?int
42
    {
43
        return $this->id;
44
    }
45
46
    public function getFirstDay(): ?\DateTimeInterface
47
    {
48
        return $this->FirstDay;
49
    }
50
51
    public function setFirstDay(\DateTimeInterface $FirstDay): static
52
    {
53
        $this->FirstDay = $FirstDay;
54
55
        return $this;
56
    }
57
58
    public function getLastDay(): ?\DateTimeInterface
59
    {
60
        return $this->LastDay;
61
    }
62
63
    public function setLastDay(\DateTimeInterface $LastDay): static
64
    {
65
        $this->LastDay = $LastDay;
66
67
        return $this;
68
    }
69
70
    public function getChartOfAccount(): ?string
71
    {
72
        return $this->ChartOfAccount;
73
    }
74
75
    public function setChartOfAccount(?string $ChartOfAccount): static
76
    {
77
        $this->ChartOfAccount = $ChartOfAccount;
78
79
        return $this;
80
    }
81
82
    /**
83
     * @return Collection<int, JournalEntry>
84
     */
85
    public function getJournalEntries(): Collection
86
    {
87
        return $this->journalEntries;
88
    }
89
90
    public function addJournalEntry(JournalEntry $journalEntry): static
91
    {
92
        if (!$this->journalEntries->contains($journalEntry)) {
93
            $this->journalEntries->add($journalEntry);
94
            $journalEntry->setJournal($this);
95
        }
96
97
        return $this;
98
    }
99
100
    public function removeJournalEntry(JournalEntry $journalEntry): static
101
    {
102
        if ($this->journalEntries->removeElement($journalEntry)) {
103
            // set the owning side to null (unless already changed)
104
            if ($journalEntry->getJournal() === $this) {
105
                $journalEntry->setJournal(null);
106
            }
107
        }
108
109
        return $this;
110
    }
111
}
112