ShippingAddressManagement   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 54
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A beforeAssign() 0 8 2
1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Model\Plugins;
28
29
use Magento\Quote\Api\Data\AddressInterface;
30
use Magento\Quote\Model\ShippingAddressManagement as ShippingAddressManagementOrig;
31
32
/**
33
 * Plugin for Magentos ShippingAddressManagement class
34
 */
35
class ShippingAddressManagement
36
{
37
    /**
38
     * Quote repository.
39
     *
40
     * @var \Magento\Quote\Api\CartRepositoryInterface
41
     */
42
    protected $quoteRepository;
43
44
    /**
45
     * PAYONE addresscheck request model
46
     *
47
     * @var \Payone\Core\Model\Risk\Addresscheck
48
     */
49
    protected $addresscheck;
50
51
    /**
52
     * @var \Magento\Framework\App\Request\Http
53
     */
54
    protected $request;
55
56
    /**
57
     * Constructor
58
     *
59
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
60
     * @param \Payone\Core\Model\Risk\Addresscheck       $addresscheck
61
     */
62
    public function __construct(
63
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
64
        \Payone\Core\Model\Risk\Addresscheck $addresscheck,
65
        \Magento\Framework\App\Request\Http $request
66
    ) {
67
        $this->quoteRepository = $quoteRepository;
68
        $this->addresscheck = $addresscheck;
69
        $this->request = $request;
70
    }
71
72
    /**
73
     * This writes the addresscheck score to the quote address
74
     * 
75
     * @param  ShippingAddressManagementOrig $oSource
76
     * @param  int                           $sCartId
77
     * @param  AddressInterface              $oAddress
78
     * @return array
79
     */
80
    public function beforeAssign(ShippingAddressManagementOrig $oSource, $sCartId, AddressInterface $oAddress)
0 ignored issues
show
Unused Code introduced by
The parameter $oSource is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
81
    {
82
        if (stripos($this->request->getPathInfo(), 'shipping-information') !== false) { // only check for the checkout ajax calls
83
            $oQuote = $this->quoteRepository->getActive($sCartId);
84
            $oAddress = $this->addresscheck->handleAddressManagement($oAddress, $oQuote, false);
85
        }
86
        return [$sCartId, $oAddress];
87
    }
88
}
89