InventoryCreateRequestEntity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 59
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequired() 0 6 1
A setSku() 0 5 1
A setStock() 0 5 1
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  RequestEntity
7
 * @package   Payever\Inventory
8
 * @author    payever GmbH <[email protected]>
9
 * @author    Hennadii.Shymanskyi <[email protected]>
10
 * @copyright 2017-2021 payever GmbH
11
 * @license   MIT <https://opensource.org/licenses/MIT>
12
 * @link      https://docs.payever.org/shopsystems/api/getting-started
13
 */
14
15
namespace Payever\ExternalIntegration\Inventory\Http\RequestEntity;
16
17
use Payever\ExternalIntegration\Core\Http\RequestEntity;
18
19
/**
20
 * @method string getSku()
21
 * @method int getStock()
22
 * @method string getExternalId()
23
 * @method self setExternalId(string $externalId)
24
 */
25
class InventoryCreateRequestEntity extends RequestEntity
26
{
27
    const UNDERSCORE_ON_SERIALIZATION = false;
28
29
    /**
30
     * Subscription external id.
31
     * Required for all requests.
32
     *
33
     * @var string
34
     */
35
    protected $externalId;
36
37
    /**
38
     * Target product SKU
39
     *
40
     * @var string
41
     */
42
    protected $sku;
43
44
    /**
45
     * Initial qty of a product.
46
     * Only first request will actually create an inventory record on payever side.
47
     * All further create requests will be ignored.
48
     *
49
     * @var int
50
     */
51
    protected $stock;
52
53
    /**
54
     * @param string $sku
55
     * @return static
56
     */
57
    public function setSku($sku)
58
    {
59
        $this->sku = (string) $sku;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @param int|float|string $stock
66
     * @return static
67
     */
68
    public function setStock($stock)
69
    {
70
        $this->stock = (int) $stock;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    public function getRequired()
79
    {
80
        return [
81
            'externalId',
82
            'sku',
83
            'stock',
84
        ];
85
    }
86
}
87