Completed
Push — master ( 407c79...c152a3 )
by Sergey
12s queued 10s
created

SmsIntel::createHttpAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace seregazhuk\SmsIntel;
4
5
use GuzzleHttp\Client;
6
use seregazhuk\SmsIntel\Api\GuzzleHttpClient;
7
use seregazhuk\SmsIntel\Api\Requests\RequestsContainer;
8
use seregazhuk\SmsIntel\Exceptions\AuthenticationFailed;
9
10
class SmsIntel
11
{
12
    /**
13
     * @param $login
14
     * @param $password
15
     * @return RequestsContainer
16
     * @throws AuthenticationFailed
17
     */
18
    public static function create($login, $password)
19
    {
20
        self::checkCredentials($login, $password);
21
22
        return new RequestsContainer(
23
			new GuzzleHttpClient(new Client()),
24
            $login,
25
            $password
26
        );
27
    }
28
29
    /**
30
     * @param string $login
31
     * @param string $password
32
     * @throws AuthenticationFailed
33
     */
34
    protected static function checkCredentials($login, $password)
35
    {
36
        if (empty($login) || empty($password)) {
37
            throw new AuthenticationFailed('You must provide login and password to send messages!');
38
        }
39
    }
40
41
    /**
42
     * @codeCoverageIgnore
43
     */
44
    private function __construct(){}
45
46
    /**
47
     * @codeCoverageIgnore
48
     */
49
    private function __clone(){}
50
}
51