StoreService::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the MailChimpEcommerceBundle package.
4
 *
5
 * Copyright (c) 2017 kevin92dev.es
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * Feel free to edit as you please, and have fun.
11
 *
12
 * @author Kevin Murillo <[email protected]>
13
 */
14
15
namespace Kevin92dev\MailChimpEcommerceBundle\Services;
16
17
use Kevin92dev\MailChimpEcommerceBundle\Entities\Store;
18
use Kevin92dev\MailChimpEcommerceBundle\RequestTypes;
19
use Kevin92dev\MailChimpEcommerceBundle\Services\MailChimp;
20
21
/**
22
 * StoreService
23
 *
24
 * @author Kevin Murillo <[email protected]>
25
 */
26
class StoreService
27
{
28
    /**
29
     * @var MailChimp
30
     */
31
    private $mailChimp;
32
33
    /**
34
     * Initializes Store
35
     *
36
     * @param MailChimp $mailChimp
37
     */
38
    public function __construct(MailChimp $mailChimp)
39
    {
40
        $this->mailChimp = $mailChimp;
41
    }
42
43
    /**
44
     * Create a new Store in MailChimp
45
     *
46
     * @var Store $store
47
     */
48
    public function create($store)
49
    {
50
        $method = RequestTypes::$POST;
51
52
        $data = [
53
            'id'            => $store->getId(),
54
            'list_id'       => $store->getListId(),
55
            'name'          => $store->getName(),
56
            'domain'        => $store->getDomain(),
57
            'email_address' => $store->getEmailAddress(),
58
            'currency_code' => $store->getCurrencyCode()
59
        ];
60
61
        $this->mailChimp->doRequest($method, json_encode($data));
0 ignored issues
show
Documentation introduced by
json_encode($data) is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
62
    }
63
}