Completed
Push — master ( d45023...b56118 )
by Ashleigh
15:50
created

Account::exists()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 5
nop 1
1
<?php
2
3
namespace Surge\LaravelSalesforce\Objects;
4
5
class Account extends AbstractObject
6
{
7
    /**
8
     * Insert new account.
9
     *
10
     * @param $params
11
     */
12
    public function create(array $params)
13
    {
14
        $params['RecordTypeId'] = config('laravel-salesforce.record_type.account');
15
16
        return parent::create($params);
17
    }
18
19
    /**
20
     * Check if account already exists on SF.
21
     * $params = [
22
     *  'PersonEmail' => '[email protected]'
23
     * ]
24
     *
25
     *
26
     * @param array $param to search
0 ignored issues
show
Documentation introduced by
There is no parameter named $param. Did you maybe mean $params?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
27
     * @return bool|array
28
     */
29
    public function exists($params)
30
    {
31
        if(empty($params)) {
32
            return false;
33
        }
34
35
        $query = 'SELECT Id, OwnerId  FROM ' . $this->getType() . ' WHERE RecordTypeId = \'' . config('laravel-salesforce.record_type.account') . '\'';
36
37
        foreach($params as $fieldName => $fieldValue) {
38
            $query .= ' AND ' . $fieldName . '=\'' . addslashes(trim($fieldValue)) . '\'';
39
        }
40
41
        $response = $this->query($query);
42
43
        if ($response && $response->totalSize > 0) {
44
            return array_shift($response->records);
45
        }
46
47
        return false;
48
    }
49
}
50