RequestFactory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 101
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriverConfigValue() 0 3 1
A getDriverArgumentsArray() 0 3 1
A getDriverNamePrefix() 0 3 1
A getDriverInterface() 0 3 1
A __construct() 0 4 1
A getClient() 0 3 1
A getDriverNameSuffix() 0 3 1
A getDriverNamespace() 0 3 1
1
<?php
2
3
namespace Trucker\Factories;
4
5
use Guzzle\Http\Client;
6
use Illuminate\Container\Container;
7
use Trucker\Facades\Config;
8
use Trucker\Framework\FactoryDriver;
9
10
class RequestFactory extends FactoryDriver
11
{
12
    /**
13
     * Guzzle Client attached to request
14
     * returned by build().
15
     *
16
     * @var Client
17
     */
18
    protected $client;
19
20
    /**
21
     * Build a new FactoryDriver.
22
     *
23
     * @param Container $app
24
     *
25
     * @throws \Guzzle\Common\Exception\RuntimeException
26
     */
27 1
    public function __construct(Container $app)
28
    {
29 1
        parent::__construct($app);
30 1
        $this->client = new Client();
31 1
    }
32
33
    /**
34
     * Getter function to access the HTTP Client.
35
     *
36
     * @return Client
37
     */
38 24
    public function getClient()
39
    {
40 24
        return $this->client;
41
    }
42
43
    /**
44
     * Function to return a string representaion of the namespace
45
     * that all classes built by the factory should be contained within.
46
     *
47
     * @return string - namespace string
48
     */
49 25
    public function getDriverNamespace()
50
    {
51 25
        return "\Trucker\Requests";
52
    }
53
54
    /**
55
     * Function to return the interface that the driver's produced
56
     * by the factory must implement.
57
     *
58
     * @return string
59
     */
60 24
    public function getDriverInterface()
61
    {
62 24
        return "\Trucker\Requests\RequestableInterface";
63
    }
64
65
    /**
66
     * Function to return a string that should be suffixed
67
     * to the studly-cased driver name of all the drivers
68
     * that the factory can return.
69
     *
70
     * @return string
71
     */
72 25
    public function getDriverNameSuffix()
73
    {
74 25
        return 'Request';
75
    }
76
77
    /**
78
     * Function to return a string that should be prefixed
79
     * to the studly-cased driver name of all the drivers
80
     * that the factory can return.
81
     *
82
     * @return string
83
     */
84 25
    public function getDriverNamePrefix()
85
    {
86 25
        return '';
87
    }
88
89
    /**
90
     * Function to return an array of arguments that should be
91
     * passed to the constructor of a new driver instance.
92
     *
93
     * @return array
94
     */
95 24
    public function getDriverArgumentsArray()
96
    {
97 24
        return [$this->app, $this->client];
98
    }
99
100
    /**
101
     * Function to return the string representation of the driver
102
     * itslef based on a value fetched from the config file.  This
103
     * function will itself access the config, and return the driver
104
     * setting.
105
     *
106
     * @return string
107
     */
108 25
    public function getDriverConfigValue()
109
    {
110 25
        return Config::get('request.driver');
0 ignored issues
show
Bug introduced by
The method get() does not exist on Trucker\Facades\Config. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

110
        return Config::/** @scrutinizer ignore-call */ get('request.driver');
Loading history...
111
    }
112
}
113