Issues (174)

src/Entity/PaymentMethod.php (4 issues)

1
<?php
2
3
namespace Loevgaard\DandomainFoundation\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Loevgaard\DandomainFoundation\Entity\Generated\PaymentMethodInterface;
0 ignored issues
show
The type Loevgaard\DandomainFound...\PaymentMethodInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Loevgaard\DandomainFoundation\Entity\Generated\PaymentMethodTrait;
0 ignored issues
show
The type Loevgaard\DandomainFound...ated\PaymentMethodTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Money\Currency;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Loevgaard\DandomainFoundation\Entity\Currency. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
9
use Money\Money;
10
11
/**
12
 * @ORM\Entity()
13
 * @ORM\Table(name="ldf_payment_methods")
14
 *
15
 * @todo a lot of missing properties on this entity, see http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/SettingService/help/operations/GetPaymentMethods
16
 */
17
class PaymentMethod extends AbstractEntity implements PaymentMethodInterface
18
{
19
    use PaymentMethodTrait;
20
21
    /**
22
     * @var int
23
     *
24
     * @ORM\Id
25
     * @ORM\GeneratedValue
26
     * @ORM\Column(type="integer")
27
     **/
28
    protected $id;
29
30
    /**
31
     * @var int
32
     *
33
     * @ORM\Column(type="integer", unique=true)
34
     */
35
    protected $externalId;
36
37
    /**
38
     * @var string|null
39
     *
40
     * @ORM\Column(nullable=true, type="string", length=3)
41
     */
42
    protected $feeCurrency;
43
44
    /**
45
     * @var int|null
46
     *
47
     * @ORM\Column(nullable=true, type="integer")
48
     */
49
    protected $feeAmount;
50
51
    /**
52
     * @var bool|null
53
     *
54
     * @ORM\Column(nullable=true, type="boolean")
55
     */
56
    protected $feeInclVat;
57
58
    /**
59
     * @var string|null
60
     *
61
     * @ORM\Column(nullable=true, type="string", length=191)
62
     */
63
    protected $name;
64
65
    public function __toString()
66
    {
67
        return (string) $this->name;
68
    }
69
70
    /**
71
     * @return int
72
     */
73
    public function getId(): int
74
    {
75
        return (int) $this->id;
76
    }
77
78
    /**
79
     * @param int $id
80
     *
81
     * @return PaymentMethodInterface
82
     */
83
    public function setId($id)
84
    {
85
        $this->id = $id;
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return int
92
     */
93
    public function getExternalId(): int
94
    {
95
        return (int) $this->externalId;
96
    }
97
98
    /**
99
     * @param int $externalId
100
     *
101
     * @return PaymentMethodInterface
102
     */
103
    public function setExternalId($externalId)
104
    {
105
        $this->externalId = $externalId;
106
107
        return $this;
108
    }
109
110
    /**
111
     * @return Money|null
112
     */
113
    public function getFee(): ?Money
114
    {
115
        if (!$this->feeCurrency) {
116
            return null;
117
        }
118
119
        return new Money($this->feeAmount, new Currency($this->feeCurrency));
120
    }
121
122
    /**
123
     * @param Money $money
124
     *
125
     * @return PaymentMethodInterface
126
     */
127
    public function setFee(Money $money): PaymentMethodInterface
128
    {
129
        $this->feeAmount = $money->getAmount();
0 ignored issues
show
Documentation Bug introduced by
It seems like $money->getAmount() of type string is incompatible with the declared type integer|null of property $feeAmount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
130
        $this->feeCurrency = $money->getCurrency()->getCode();
131
132
        return $this;
133
    }
134
135
    /**
136
     * @return bool|null
137
     */
138
    public function getFeeInclVat()
139
    {
140
        return $this->feeInclVat;
141
    }
142
143
    /**
144
     * @param bool|null $feeInclVat
145
     *
146
     * @return PaymentMethodInterface
147
     */
148
    public function setFeeInclVat($feeInclVat)
149
    {
150
        $this->feeInclVat = $feeInclVat;
151
152
        return $this;
153
    }
154
155
    /**
156
     * @return null|string
157
     */
158
    public function getName()
159
    {
160
        return $this->name;
161
    }
162
163
    /**
164
     * @param null|string $name
165
     *
166
     * @return PaymentMethodInterface
167
     */
168
    public function setName($name)
169
    {
170
        $this->name = $name;
171
172
        return $this;
173
    }
174
}
175