SiftScienceService::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 2
nop 0
1
<?php
2
3
namespace Pablumfication\LaravelSiftScience\Services;
4
5
class SiftScienceService
6
{
7
8
    /**
9
     * Get auth parameters from config, fail if any are missing.
10
     * Instantiate API client and set auth token.
11
     *
12
     * @throws Exception
13
     */
14
    public function __construct()
15
    {
16
        $this->api_key = config('laravel-sift-science.api_key');
0 ignored issues
show
Bug introduced by
The property api_key does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
        $this->account_id = config('laravel-sift-science.account_id');
0 ignored issues
show
Bug introduced by
The property account_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
        $this->timeout = config('laravel-sift-science.timeout');
0 ignored issues
show
Bug introduced by
The property timeout does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
19
        $this->version = config('laravel-sift-science.version');
0 ignored issues
show
Bug introduced by
The property version does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
21
        if (!$this->api_key || !$this->account_id) {
22
            throw new \InvalidArgumentException(
23
                'Please set SIFT_SCIENCE_API_KEY and SIFT_SCIENCE_ACCOUNT_ID environment variables.'
24
            );
25
        }
26
27
        $this->siftclient = new \SiftClient([
0 ignored issues
show
Bug introduced by
The property siftclient does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
            'api_key' => $this->api_key,
29
            'account_id' => $this->account_id,
30
        ]);
31
    }
32
33
    /**
34
     * Pass any method calls onto $this->siftclient
35
     *
36
     * @return mixed
37
     */
38
    public function __call($method, $args)
39
    {
40
        if (is_callable([$this->siftclient, $method])) {
41
            return call_user_func_array([$this->siftclient, $method], $args);
42
        } else {
43
            throw new \BadMethodCallException("Method $method does not exist");
44
        }
45
    }
46
}
47