PaymentItemEntity::isValid()   B
last analyzed

Complexity

Conditions 7
Paths 15

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
rs 8.8333
cc 7
nc 15
nop 0
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  RequestEntity
7
 * @package   Payever\Payments
8
 * @author    payever GmbH <[email protected]>
9
 * @copyright 2017-2021 payever GmbH
10
 * @license   MIT <https://opensource.org/licenses/MIT>
11
 * @link      https://docs.payever.org/shopsystems/api/getting-started
12
 */
13
14
namespace Payever\ExternalIntegration\Payments\Http\RequestEntity;
15
16
use Payever\ExternalIntegration\Core\Http\RequestEntity;
17
18
/**
19
 * This class represents Payment Item RequestInterface Entity
20
 *
21
 * @method string    getName()
22
 * @method string    getIdentifier()
23
 * @method float     getPrice()
24
 * @method integer   getQuantity()
25
 * @method self      setName(string $name)
26
 * @method self      setIdentifier(string $identifier)
27
 * @method self      setPrice(float $price)
28
 * @method self      setQuantity(integer $quantity)
29
 */
30
class PaymentItemEntity extends RequestEntity
31
{
32
    /** @var string $name */
33
    protected $name;
34
35
    /** @var string $identifier */
36
    protected $identifier;
37
38
    /** @var float $price */
39
    protected $price;
40
41
    /** @var integer $quantity */
42
    protected $quantity;
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function isValid()
48
    {
49
        return parent::isValid() &&
50
            (!$this->identifier || is_string($this->identifier)) &&
51
            (!$this->price || is_numeric($this->price)) &&
52
            (!$this->quantity || is_numeric($this->quantity));
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function toArray($object = null)
59
    {
60
        return $object ? get_object_vars($object) : get_object_vars($this);
61
    }
62
}
63