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

SmsIntel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 4
dl 0
loc 41
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 1
A checkCredentials() 0 6 3
A __construct() 0 1 1
A __clone() 0 1 1
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