Code Duplication    Length = 18-19 lines in 3 locations

src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactAddressController.php 1 location

@@ 67-85 (lines=19) @@
64
     *
65
     * @return JsonResponse
66
     */
67
    public function cgetAction($contactId)
68
    {
69
        /** @var Contact $contact */
70
        $contact = $this->getContactManager()->find($contactId);
71
        $result  = [];
72
73
        if (!empty($contact)) {
74
            $items = $contact->getAddresses();
75
76
            foreach ($items as $item) {
77
                $result[] = $this->getPreparedItem($item);
78
            }
79
        }
80
81
        return new JsonResponse(
82
            $result,
83
            empty($contact) ? Codes::HTTP_NOT_FOUND : Codes::HTTP_OK
84
        );
85
    }
86
87
    /**
88
     * REST DELETE address

src/OroCRM/Bundle/MagentoBundle/Controller/Api/Rest/CustomerAddressController.php 1 location

@@ 43-61 (lines=19) @@
40
     *
41
     * @return JsonResponse
42
     */
43
    public function cgetAction($customerId)
44
    {
45
        /** @var Customer $customer */
46
        $customer = $this->getCustomerManager()->find($customerId);
47
        $result   = [];
48
49
        if ($customer instanceof Customer) {
50
            $items = $customer->getAddresses();
51
52
            foreach ($items as $item) {
53
                $result[] = $this->getPreparedItem($item);
54
            }
55
        }
56
57
        return new JsonResponse(
58
            $result,
59
            empty($customer) ? Codes::HTTP_NOT_FOUND : Codes::HTTP_OK
60
        );
61
    }
62
63
    /**
64
     * Add address to the customer.

src/OroCRM/Bundle/ContactBundle/Controller/Api/Rest/ContactPhoneController.php 1 location

@@ 39-56 (lines=18) @@
36
     * @param int $contactId
37
     * @return Response
38
     */
39
    public function cgetAction($contactId)
40
    {
41
        /** @var Contact $contact */
42
        $contact = $this->getContactManager()->find($contactId);
43
        $result = [];
44
        if (!empty($contact)) {
45
            $items = $contact->getPhones();
46
47
            foreach ($items as $item) {
48
                $result[] = $this->getPreparedItem($item);
49
            }
50
        }
51
52
        return new JsonResponse(
53
            $result,
54
            empty($contact) ? Codes::HTTP_NOT_FOUND : Codes::HTTP_OK
55
        );
56
    }
57
58
    /**
59
     * REST GET primary phone