Code Duplication    Length = 92-94 lines in 2 locations

src/Model/BillingAddressTrait.php 1 location

@@ 8-101 (lines=94) @@
5
use Xsolve\SalesforceClient\Model\ValueObject\Address;
6
use JMS\Serializer\Annotation as JMS;
7
8
trait BillingAddressTrait
9
{
10
    /**
11
     * @var string|null
12
     * @JMS\Type("string")
13
     * @JMS\Groups({"update", "create"})
14
     */
15
    protected $billingStreet;
16
17
    /**
18
     * @var string|null
19
     * @JMS\Type("string")
20
     * @JMS\Groups({"update", "create"})
21
     */
22
    protected $billingCity;
23
24
    /**
25
     * @var string|null
26
     * @JMS\Type("string")
27
     * @JMS\Groups({"update", "create"})
28
     */
29
    protected $billingState;
30
31
    /**
32
     * @var string|null
33
     * @JMS\Type("string")
34
     * @JMS\Groups({"update", "create"})
35
     */
36
    protected $billingPostalCode;
37
38
    /**
39
     * @var string|null
40
     * @JMS\Type("string")
41
     * @JMS\Groups({"update", "create"})
42
     */
43
    protected $billingCountry;
44
45
    /**
46
     * @var float|null
47
     * @JMS\Type("float")
48
     * @JMS\Groups({"update", "create"})
49
     */
50
    protected $billingLatitude;
51
52
    /**
53
     * @var float|null
54
     * @JMS\Type("float")
55
     * @JMS\Groups({"update", "create"})
56
     */
57
    protected $billingLongitude;
58
59
    /**
60
     * @var Address|null
61
     * @JMS\Type("Xsolve\SalesforceClient\Model\ValueObject\Address")
62
     */
63
    protected $billingAddress;
64
65
    /**
66
     * @return Address|null
67
     */
68
    public function getBillingAddress()
69
    {
70
        return $this->billingAddress;
71
    }
72
73
74
    public function setBillingAddress(Address $billingAddress): self
75
    {
76
        $this->billingAddress = $billingAddress;
77
78
        return $this;
79
    }
80
81
82
    /**
83
     * Because BillingAddress is not writtable.
84
     *
85
     * @JMS\PreSerialize
86
     */
87
    public function updateBillingAddress()
88
    {
89
        if (!$this->billingAddress instanceof Address) {
90
            return;
91
        }
92
93
        $this->billingCity = $this->billingAddress->getCity();
94
        $this->billingCountry = $this->billingAddress->getCountry();
95
        $this->billingLatitude = $this->billingAddress->getLatitude();
96
        $this->billingLongitude = $this->billingAddress->getLongitude();
97
        $this->billingPostalCode = $this->billingAddress->getPostalCode();
98
        $this->billingState = $this->billingAddress->getState();
99
        $this->billingStreet = $this->billingAddress->getStreet();
100
    }
101
}
102

src/Model/ShippingAddressTrait.php 1 location

@@ 8-99 (lines=92) @@
5
use Xsolve\SalesforceClient\Model\ValueObject\Address;
6
use JMS\Serializer\Annotation as JMS;
7
8
trait ShippingAddressTrait
9
{
10
    /**
11
     * @var string|null
12
     * @JMS\Type("string")
13
     * @JMS\Groups({"update", "create"})
14
     */
15
    protected $shippingStreet;
16
17
    /**
18
     * @var string|null
19
     * @JMS\Type("string")
20
     * @JMS\Groups({"update", "create"})
21
     */
22
    protected $shippingCity;
23
24
    /**
25
     * @var string|null
26
     * @JMS\Type("string")
27
     * @JMS\Groups({"update", "create"})
28
     */
29
    protected $shippingState;
30
31
    /**
32
     * @var string|null
33
     * @JMS\Type("string")
34
     * @JMS\Groups({"update", "create"})
35
     */
36
    protected $shippingPostalCode;
37
38
    /**
39
     * @var string|null
40
     * @JMS\Type("string")
41
     * @JMS\Groups({"update", "create"})
42
     */
43
    protected $shippingCountry;
44
45
    /**
46
     * @var float|null
47
     * @JMS\Type("float")
48
     * @JMS\Groups({"update", "create"})
49
     */
50
    protected $shippingLatitude;
51
52
    /**
53
     * @var float|null
54
     * @JMS\Type("float")
55
     * @JMS\Groups({"update", "create"})
56
     */
57
    protected $shippingLongitude;
58
59
    /**
60
     * @var Address|null
61
     * @JMS\Type("Xsolve\SalesforceClient\Model\ValueObject\Address")
62
     */
63
    protected $shippingAddress;
64
65
    /**
66
     * @return Address|null
67
     */
68
    public function getShippingAddress()
69
    {
70
        return $this->shippingAddress;
71
    }
72
73
    public function setShippingAddress(Address $shippingAddress): self
74
    {
75
        $this->shippingAddress = $shippingAddress;
76
77
        return $this;
78
    }
79
80
    /**
81
     * Because ShippingAddress is not writable.
82
     *
83
     * @JMS\PreSerialize
84
     */
85
    public function updateShippingAddress()
86
    {
87
        if (!$this->shippingAddress instanceof Address) {
88
            return;
89
        }
90
91
        $this->shippingCity = $this->shippingAddress->getCity();
92
        $this->shippingCountry = $this->shippingAddress->getCountry();
93
        $this->shippingLatitude = $this->shippingAddress->getLatitude();
94
        $this->shippingLongitude = $this->shippingAddress->getLongitude();
95
        $this->shippingPostalCode = $this->shippingAddress->getPostalCode();
96
        $this->shippingState = $this->shippingAddress->getState();
97
        $this->shippingStreet = $this->shippingAddress->getStreet();
98
    }
99
}
100