AccountingDocument::getTransaction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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
ccs 0
cts 2
cp 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Application\Repository\AccountingDocumentRepository;
8
use Doctrine\ORM\Mapping as ORM;
9
10
/**
11
 * A document attesting an expense claim.
12
 */
13
#[ORM\UniqueConstraint(name: 'unique_name', columns: ['filename'])]
14
#[ORM\HasLifecycleCallbacks]
15
#[ORM\Entity(AccountingDocumentRepository::class)]
16
class AccountingDocument extends AbstractModel implements \Ecodev\Felix\Model\File
17
{
18
    use \Ecodev\Felix\Model\Traits\File;
19
20 3
    protected function getBasePath(): string
21
    {
22 3
        return 'data/accounting/';
23
    }
24
25
    #[ORM\JoinColumn(onDelete: 'CASCADE')]
26
    #[ORM\ManyToOne(targetEntity: ExpenseClaim::class, inversedBy: 'accountingDocuments')]
27
    private ?ExpenseClaim $expenseClaim = null;
28
29
    #[ORM\JoinColumn(onDelete: 'CASCADE')]
30
    #[ORM\ManyToOne(targetEntity: Transaction::class, inversedBy: 'accountingDocuments')]
31
    private ?Transaction $transaction = null;
32
33 7
    public function setExpenseClaim(?ExpenseClaim $expenseClaim): void
34
    {
35 7
        if ($this->expenseClaim) {
36 1
            $this->expenseClaim->accountingDocumentRemoved($this);
37
        }
38
39 7
        $this->expenseClaim = $expenseClaim;
40
41 7
        if ($this->expenseClaim) {
42 7
            $expenseClaim->accountingDocumentAdded($this);
0 ignored issues
show
Bug introduced by
The method accountingDocumentAdded() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
            $expenseClaim->/** @scrutinizer ignore-call */ 
43
                           accountingDocumentAdded($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
        }
44
    }
45
46 3
    public function getExpenseClaim(): ?ExpenseClaim
47
    {
48 3
        return $this->expenseClaim;
49
    }
50
51 1
    public function setTransaction(?Transaction $transaction): void
52
    {
53 1
        if ($this->transaction) {
54 1
            $this->transaction->accountingDocumentRemoved($this);
55
        }
56
57 1
        $this->transaction = $transaction;
58
59 1
        if ($this->transaction) {
60 1
            $transaction->accountingDocumentAdded($this);
0 ignored issues
show
Bug introduced by
The method accountingDocumentAdded() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
            $transaction->/** @scrutinizer ignore-call */ 
61
                          accountingDocumentAdded($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
61
        }
62
    }
63
64
    public function getTransaction(): ?Transaction
65
    {
66
        return $this->transaction;
67
    }
68
}
69