Promotions::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace Resova\Endpoints\Baskets;
4
5
use Resova\Client;
6
use Resova\Models\PromotionRequest;
7
8
class Promotions extends Client
9
{
10
    /**
11
     * Create a basket promotion
12
     * Creates a new basket promotion object.
13
     *
14
     * @param PromotionRequest $promotion
15
     *
16
     * @return $this
17
     */
18
    public function create(PromotionRequest $promotion): self
19
    {
20
        // Set HTTP params
21
        $this->type     = 'post';
22
        $this->endpoint = '/baskets/' . $this->basket_id . '/promotions';
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

22
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/promotions';
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Promotions. Since you implemented __get, consider adding a @property annotation.
Loading history...
23
        $this->params   = $promotion;
24
25
        return $this;
26
    }
27
28
    /**
29
     * Retrieve a basket promotion
30
     * Retrieves the details of a basket promotion. Provide the unique id for the basket promotion.
31
     *
32
     * @param int $promotion_id The basket promotion id
33
     *
34
     * @return $this
35
     */
36
    public function __invoke(int $promotion_id): self
37
    {
38
        $this->promotion_id = $promotion_id;
0 ignored issues
show
Bug Best Practice introduced by
The property promotion_id does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
40
        // Set HTTP params
41
        $this->type     = 'get';
42
        $this->endpoint = '/baskets/' . $this->basket_id . '/promotions/' . $promotion_id;
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

42
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/promotions/' . $promotion_id;
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Promotions. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
44
        return $this;
45
    }
46
47
    /**
48
     * Delete a basket promotion
49
     * Permanently deletes a basket promotion. It cannot be undone.
50
     *
51
     * @return $this
52
     */
53
    public function delete(): self
54
    {
55
        // Set HTTP params
56
        $this->type     = 'delete';
57
        $this->endpoint = '/baskets/' . $this->basket_id . '/promotions/' . $this->promotion_id;
0 ignored issues
show
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Promotions. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

57
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/promotions/' . $this->promotion_id;
Loading history...
58
59
        return $this;
60
    }
61
62
    /**
63
     * List all basket promotions
64
     * Returns a list of your basket promotions.
65
     * The basket promotions are returned sorted by creation date, with the most recent basket purchase appearing first.
66
     *
67
     * @return $this
68
     */
69
    public function all(): self
70
    {
71
        // Set HTTP params
72
        $this->type     = 'get';
73
        $this->endpoint = '/baskets/' . $this->basket_id . '/promotions';
0 ignored issues
show
Bug introduced by
Are you sure $this->basket_id of type boolean|object can be used in concatenation? ( Ignorable by Annotation )

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

73
        $this->endpoint = '/baskets/' . /** @scrutinizer ignore-type */ $this->basket_id . '/promotions';
Loading history...
Bug Best Practice introduced by
The property basket_id does not exist on Resova\Endpoints\Baskets\Promotions. Since you implemented __get, consider adding a @property annotation.
Loading history...
74
75
        return $this;
76
    }
77
}
78