WishlistsApiTester::buildWishlistItemUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace PyzTest\Glue\Wishlists;
11
12
use Spryker\Glue\GlueApplication\Rest\RequestConstantsInterface;
13
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig;
14
use Spryker\Glue\WishlistsRestApi\WishlistsRestApiConfig;
15
use SprykerTest\Glue\Testify\Tester\ApiEndToEndTester;
16
17
/**
18
 * Inherited Methods
19
 *
20
 * @method void wantToTest($text)
21
 * @method void wantTo($text)
22
 * @method void execute($callable)
23
 * @method void expectTo($prediction)
24
 * @method void expect($prediction)
25
 * @method void amGoingTo($argumentation)
26
 * @method void am($role)
27
 * @method void lookForwardTo($achieveValue)
28
 * @method void comment($description)
29
 * @method void pause()
30
 *
31
 * @SuppressWarnings(\PyzTest\Glue\Wishlists\PHPMD)
32
 */
33
class WishlistsApiTester extends ApiEndToEndTester
34
{
35
    use _generated\WishlistsApiTesterActions;
0 ignored issues
show
Bug introduced by
The type PyzTest\Glue\Wishlists\_...shlistsApiTesterActions 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...
36
37
    /**
38
     * @param array<string> $includes
39
     *
40
     * @return string
41
     */
42
    public function formatQueryInclude(array $includes = []): string
43
    {
44
        if (!$includes) {
45
            return '';
46
        }
47
48
        return sprintf('?%s=%s', RequestConstantsInterface::QUERY_INCLUDE, implode(',', $includes));
49
    }
50
51
    /**
52
     * @param array<string> $includes
53
     *
54
     * @return string
55
     */
56
    public function buildWishlistsUrl(array $includes = []): string
57
    {
58
        return $this->formatFullUrl(
59
            '{resourceWishlists}' . $this->formatQueryInclude($includes),
60
            [
61
                'resourceWishlists' => WishlistsRestApiConfig::RESOURCE_WISHLISTS,
62
            ],
63
        );
64
    }
65
66
    /**
67
     * @param string $wishlistUuid
68
     * @param array<string> $includes
69
     *
70
     * @return string
71
     */
72
    public function buildWishlistUrl(string $wishlistUuid, array $includes = []): string
73
    {
74
        return $this->formatFullUrl(
75
            '{resourceWishlists}/{wishlistUuid}' . $this->formatQueryInclude($includes),
76
            [
77
                'resourceWishlists' => WishlistsRestApiConfig::RESOURCE_WISHLISTS,
78
                'wishlistUuid' => $wishlistUuid,
79
            ],
80
        );
81
    }
82
83
    /**
84
     * @param string $wishlistUuid
85
     * @param string $productConcreteSku
86
     * @param array<string> $includes
87
     *
88
     * @return string
89
     */
90
    public function buildWishlistItemUrl(string $wishlistUuid, string $productConcreteSku, array $includes = []): string
91
    {
92
        return $this->formatFullUrl(
93
            '{resourceWishlists}/{wishlistUuid}/{resourceWishlistItems}/{productConcreteSku}' . $this->formatQueryInclude($includes),
94
            [
95
                'resourceWishlists' => WishlistsRestApiConfig::RESOURCE_WISHLISTS,
96
                'wishlistUuid' => $wishlistUuid,
97
                'resourceWishlistItems' => WishlistsRestApiConfig::RESOURCE_WISHLIST_ITEMS,
98
                'productConcreteSku' => $productConcreteSku,
99
            ],
100
        );
101
    }
102
103
    /**
104
     * @param string $productConcreteSku
105
     * @param array<string> $includes
106
     *
107
     * @return string
108
     */
109
    public function buildProductConcreteUrl(string $productConcreteSku, array $includes = []): string
110
    {
111
        return $this->formatFullUrl(
112
            '{resourceConcreteProducts}/{productConcreteSku}' . $this->formatQueryInclude($includes),
113
            [
114
                'resourceConcreteProducts' => ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS,
115
                'productConcreteSku' => $productConcreteSku,
116
            ],
117
        );
118
    }
119
}
120