Passed
Push — trunk ( 9dbac0...d20c2d )
by Christian
11:37 queued 12s
created

ShippingMethodRouteHook::getCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Shipping\Hook;
4
5
use Shopware\Core\Checkout\Shipping\ShippingMethodCollection;
6
use Shopware\Core\Framework\Script\Execution\Awareness\SalesChannelContextAwareTrait;
7
use Shopware\Core\System\SalesChannel\SalesChannelContext;
8
use Shopware\Core\System\SalesChannel\StoreApiRequestHook;
9
10
/**
11
 * Triggered when ShippingMethodRoute is requested
12
 *
13
 * @package checkout
14
 *
15
 * @hook-use-case data_loading
16
 *
17
 * @since 6.5.0.0
18
 */
19
class ShippingMethodRouteHook extends StoreApiRequestHook
20
{
21
    use SalesChannelContextAwareTrait;
22
23
    public const HOOK_NAME = 'shipping-method-route-request';
24
25
    /**
26
     * @internal
27
     */
28
    public function __construct(
29
        private readonly ShippingMethodCollection $collection,
30
        private readonly bool $onlyAvailable,
31
        protected SalesChannelContext $salesChannelContext
32
    ) {
33
        parent::__construct($salesChannelContext->getContext());
34
    }
35
36
    public function getName(): string
37
    {
38
        return self::HOOK_NAME;
39
    }
40
41
    public function getCollection(): ShippingMethodCollection
42
    {
43
        return $this->collection;
44
    }
45
46
    public function isOnlyAvailable(): bool
47
    {
48
        return $this->onlyAvailable;
49
    }
50
}
51