CreateCustomerProfileRequest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace CommerceGuys\AuthNet;
4
5
use GuzzleHttp\Client;
6
use CommerceGuys\AuthNet\DataTypes\Profile;
7
use CommerceGuys\AuthNet\Request\RequestInterface;
8
9
/**
10
 * Create a new customer profile.
11
 *
12
 * @link http://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
13
 */
14
class CreateCustomerProfileRequest extends BaseApiRequest
15
{
16
    protected $profile;
17
    protected $validationMode = 'testMode';
18
19 3
    public function __construct(
20
        Configuration $configuration,
21
        Client $client,
22
        Profile $profile = null
23
    ) {
24 3
        parent::__construct($configuration, $client);
25 3
        $this->profile = $profile;
26 3
    }
27
28
    /**
29
     * @param \CommerceGuys\AuthNet\DataTypes\Profile $profile
30
     */
31 3
    public function setProfile($profile)
32
    {
33 3
        $this->profile = $profile;
34 3
    }
35
36
    /**
37
     * @param string $validationMode
38
     */
39 2
    public function setValidationMode($validationMode)
40
    {
41 2
        $this->validationMode = $validationMode;
42 2
    }
43
44 3
    protected function attachData(RequestInterface $request)
45
    {
46 3
        $request->addDataType($this->profile);
0 ignored issues
show
Bug introduced by
It seems like $this->profile can also be of type null; however, parameter $data of CommerceGuys\AuthNet\Req...nterface::addDataType() does only seem to accept CommerceGuys\AuthNet\DataTypes\DataTypeInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

46
        $request->addDataType(/** @scrutinizer ignore-type */ $this->profile);
Loading history...
47 3
        if ($this->validationMode == 'testMode' || $this->validationMode == 'liveMode') {
48 1
            $request->addData('validationMode', $this->validationMode);
49 1
        }
50 3
    }
51
}
52