Completed
Push — master ( 408edc...841b8f )
by Sergey
02:35
created
src/Api/Endpoints/EndpointsContainer.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     }
46 46
 
47 47
     /**
48
-     * @param $endpoint
48
+     * @param string $endpoint
49 49
      * @throws WrongEndpoint
50 50
      */
51 51
     protected function addProvider($endpoint)
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,63 +8,63 @@
 block discarded – undo
8 8
 
9 9
 class EndpointsContainer
10 10
 {
11
-    const ENDPOINTS_NAMESPACE = 'seregazhuk\\Favro\\Api\\Endpoints\\';
11
+	const ENDPOINTS_NAMESPACE = 'seregazhuk\\Favro\\Api\\Endpoints\\';
12 12
 
13
-    /*
13
+	/*
14 14
     * @var HttpInterface
15 15
     */
16
-    protected $http;
16
+	protected $http;
17 17
 
18
-    /*
18
+	/*
19 19
      * @var array
20 20
      */
21
-    protected $endpoints = [];
21
+	protected $endpoints = [];
22 22
 
23
-    /**
24
-     * @param HttpClient $http
25
-     */
26
-    public function __construct(HttpClient $http)
27
-    {
28
-        $this->http = $http;
29
-    }
23
+	/**
24
+	 * @param HttpClient $http
25
+	 */
26
+	public function __construct(HttpClient $http)
27
+	{
28
+		$this->http = $http;
29
+	}
30 30
 
31
-    /**
32
-     * @param string $endpoint
33
-     * @return Endpoint
34
-     */
35
-    public function resolve($endpoint)
36
-    {
37
-        $endpoint = strtolower($endpoint);
31
+	/**
32
+	 * @param string $endpoint
33
+	 * @return Endpoint
34
+	 */
35
+	public function resolve($endpoint)
36
+	{
37
+		$endpoint = strtolower($endpoint);
38 38
 
39
-        // Check if an instance has already been initiated
40
-        if (!isset($this->endpoints[$endpoint])) {
41
-            $this->addProvider($endpoint);
42
-        }
39
+		// Check if an instance has already been initiated
40
+		if (!isset($this->endpoints[$endpoint])) {
41
+			$this->addProvider($endpoint);
42
+		}
43 43
 
44
-        return $this->endpoints[$endpoint];
45
-    }
44
+		return $this->endpoints[$endpoint];
45
+	}
46 46
 
47
-    /**
48
-     * @param $endpoint
49
-     * @throws WrongEndpoint
50
-     */
51
-    protected function addProvider($endpoint)
52
-    {
53
-        $className = self::ENDPOINTS_NAMESPACE . ucfirst($endpoint);
47
+	/**
48
+	 * @param $endpoint
49
+	 * @throws WrongEndpoint
50
+	 */
51
+	protected function addProvider($endpoint)
52
+	{
53
+		$className = self::ENDPOINTS_NAMESPACE . ucfirst($endpoint);
54 54
 
55
-        if (!class_exists($className)) {
56
-            throw new WrongEndpoint("Endpoint $className not found.");
57
-        }
55
+		if (!class_exists($className)) {
56
+			throw new WrongEndpoint("Endpoint $className not found.");
57
+		}
58 58
 
59
-        $this->endpoints[$endpoint] = $this->buildEndpoint($className);
60
-    }
59
+		$this->endpoints[$endpoint] = $this->buildEndpoint($className);
60
+	}
61 61
 
62
-    /**
63
-     * @param string $className
64
-     * @return Endpoint|object
65
-     */
66
-    protected function buildEndpoint($className)
67
-    {
68
-        return (new ReflectionClass($className))->newInstanceArgs([$this->http]);
69
-    }
62
+	/**
63
+	 * @param string $className
64
+	 * @return Endpoint|object
65
+	 */
66
+	protected function buildEndpoint($className)
67
+	{
68
+		return (new ReflectionClass($className))->newInstanceArgs([$this->http]);
69
+	}
70 70
 }
71 71
\ No newline at end of file
Please login to merge, or discard this patch.
src/Favro.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,36 +8,36 @@
 block discarded – undo
8 8
 
9 9
 class Favro
10 10
 {
11
-    /**
12
-     * @param string $login
13
-     * @param string $password
14
-     * @return Api
15
-     */
16
-    public static function create($login, $password)
17
-    {
18
-        $endpointsContainer = new EndpointsContainer(
19
-            self::getHttpInterfaceAdapter($login, $password)
20
-        );
21
-        return new Api($endpointsContainer);
22
-    }
11
+	/**
12
+	 * @param string $login
13
+	 * @param string $password
14
+	 * @return Api
15
+	 */
16
+	public static function create($login, $password)
17
+	{
18
+		$endpointsContainer = new EndpointsContainer(
19
+			self::getHttpInterfaceAdapter($login, $password)
20
+		);
21
+		return new Api($endpointsContainer);
22
+	}
23 23
 
24
-    /**
25
-     * @param string $login
26
-     * @param string $password
27
-     * @return GuzzleHttpClient
28
-     */
29
-    protected static function getHttpInterfaceAdapter($login, $password)
30
-    {
31
-        return new GuzzleHttpClient(
32
-            new Client(['auth' => [$login, $password]])
33
-        );
34
-    }
24
+	/**
25
+	 * @param string $login
26
+	 * @param string $password
27
+	 * @return GuzzleHttpClient
28
+	 */
29
+	protected static function getHttpInterfaceAdapter($login, $password)
30
+	{
31
+		return new GuzzleHttpClient(
32
+			new Client(['auth' => [$login, $password]])
33
+		);
34
+	}
35 35
 
36
-    private function __construct()
37
-    {
38
-    }
36
+	private function __construct()
37
+	{
38
+	}
39 39
 
40
-    private function __clone()
41
-    {
42
-    }
40
+	private function __clone()
41
+	{
42
+	}
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
src/Api/Endpoints/Endpoint.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -6,93 +6,93 @@
 block discarded – undo
6 6
 
7 7
 class Endpoint
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $allowedMethods = [
13
-        'getById',
14
-        'getAll',
15
-        'create',
16
-        'update',
17
-        'delete',
18
-    ];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $allowedMethods = [
13
+		'getById',
14
+		'getAll',
15
+		'create',
16
+		'update',
17
+		'delete',
18
+	];
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $endpoint;
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $endpoint;
24 24
 
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $headers = [];
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $headers = [];
29 29
 
30
-    /**
31
-     * @var HttpClient
32
-     */
33
-    protected $http;
30
+	/**
31
+	 * @var HttpClient
32
+	 */
33
+	protected $http;
34 34
 
35
-    /**
36
-     * @param HttpClient $http
37
-     */
38
-    public function __construct(HttpClient $http)
39
-    {
40
-        $this->http = $http;
41
-    }
35
+	/**
36
+	 * @param HttpClient $http
37
+	 */
38
+	public function __construct(HttpClient $http)
39
+	{
40
+		$this->http = $http;
41
+	}
42 42
 
43
-    /**
44
-     * @param string $verb
45
-     * @return string
46
-     */
47
-    public function makeRequestUrl($verb = '')
48
-    {
49
-        return "https://favro.com/api/v1/{$this->endpoint}/$verb";
50
-    }
43
+	/**
44
+	 * @param string $verb
45
+	 * @return string
46
+	 */
47
+	public function makeRequestUrl($verb = '')
48
+	{
49
+		return "https://favro.com/api/v1/{$this->endpoint}/$verb";
50
+	}
51 51
 
52
-    /**
53
-     * @param string $method
54
-     * @return bool
55
-     */
56
-    public function isMethodAllowed($method)
57
-    {
58
-        return in_array($method, $this->allowedMethods);
59
-    }
52
+	/**
53
+	 * @param string $method
54
+	 * @return bool
55
+	 */
56
+	public function isMethodAllowed($method)
57
+	{
58
+		return in_array($method, $this->allowedMethods);
59
+	}
60 60
 
61
-    /**
62
-     * @return HttpClient
63
-     */
64
-    public function getHttp()
65
-    {
66
-        return $this->http;
67
-    }
61
+	/**
62
+	 * @return HttpClient
63
+	 */
64
+	public function getHttp()
65
+	{
66
+		return $this->http;
67
+	}
68 68
 
69
-    /**
70
-     * @param array $params
71
-     * @return array
72
-     */
73
-    public function getAll(array $params = [])
74
-    {
75
-        return $this->getHttp()->get(
76
-            $this->makeRequestUrl(), $params, $this->getHeaders()
77
-        );
78
-    }
69
+	/**
70
+	 * @param array $params
71
+	 * @return array
72
+	 */
73
+	public function getAll(array $params = [])
74
+	{
75
+		return $this->getHttp()->get(
76
+			$this->makeRequestUrl(), $params, $this->getHeaders()
77
+		);
78
+	}
79 79
 
80
-    /**
81
-     * @param string $id
82
-     * @return array
83
-     */
84
-    public function getById($id)
85
-    {
86
-        return $this->getHttp()->get(
87
-            $this->makeRequestUrl($id), [], $this->getHeaders()
88
-        );
89
-    }
80
+	/**
81
+	 * @param string $id
82
+	 * @return array
83
+	 */
84
+	public function getById($id)
85
+	{
86
+		return $this->getHttp()->get(
87
+			$this->makeRequestUrl($id), [], $this->getHeaders()
88
+		);
89
+	}
90 90
 
91
-    /**
92
-     * @return array
93
-     */
94
-    protected function getHeaders()
95
-    {
96
-        return $this->headers;
97
-    }
91
+	/**
92
+	 * @return array
93
+	 */
94
+	protected function getHeaders()
95
+	{
96
+		return $this->headers;
97
+	}
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.