BraintreeToShipmentClientBridge   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getAvailableMethods() 0 16 3
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\Braintree\Dependency\Client;
9
10
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
11
use Generated\Shared\Transfer\ShipmentMethodsCollectionTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...thodsCollectionTransfer 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...
12
use Generated\Shared\Transfer\ShipmentMethodsTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\ShipmentMethodsTransfer 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...
13
14
class BraintreeToShipmentClientBridge implements BraintreeToShipmentClientInterface
15
{
16
    /**
17
     * @var \Spryker\Client\Shipment\ShipmentClientInterface
18
     */
19
    protected $shipmentClient;
20
21
    /**
22
     * @param \Spryker\Client\Shipment\ShipmentClientInterface $shipmentClient
23
     */
24
    public function __construct($shipmentClient)
25
    {
26
        $this->shipmentClient = $shipmentClient;
27
    }
28
29
    /**
30
     * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
31
     *
32
     * @return \Generated\Shared\Transfer\ShipmentMethodsTransfer
33
     */
34
    public function getAvailableMethods(QuoteTransfer $quoteTransfer): ShipmentMethodsTransfer
35
    {
36
        if (method_exists($this->shipmentClient, 'getAvailableMethodsByShipment') === true) {
37
            $shipmentMethodsCollectionTransfer = $this->shipmentClient->getAvailableMethodsByShipment($quoteTransfer);
38
39
            if ($shipmentMethodsCollectionTransfer->getShipmentMethods()->count() > 1) {
40
                throw new \RuntimeException('Split shipping is not supported');
41
            }
42
43
            $shipmentMethodsTransfer = $shipmentMethodsCollectionTransfer->getShipmentMethods()->getIterator()
44
                ->current();
45
46
            return  $shipmentMethodsTransfer;
47
        }
48
49
        return $this->shipmentClient->getAvailableMethods($quoteTransfer);
0 ignored issues
show
Bug introduced by
The method getAvailableMethods() does not exist on Spryker\Client\Shipment\ShipmentClientInterface. Did you maybe mean getAvailableMethodsByShipment()? ( Ignorable by Annotation )

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

49
        return $this->shipmentClient->/** @scrutinizer ignore-call */ getAvailableMethods($quoteTransfer);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
    }
51
}
52