Completed
Pull Request — master (#21)
by Alexander
01:13
created

SmsIntel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
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\Requests\RequestsContainer;
7
use seregazhuk\SmsIntel\Exceptions\AuthenticationFailedException;
8
9
class SmsIntel
10
{
11
    /**
12
     * @param $login
13
     * @param $password
14
     * @return RequestsContainer
15
     * @throws AuthenticationFailedException
16
     */
17
    public static function create($login, $password)
18
    {
19
        self::checkCredentials($login, $password);
20
21
        return new RequestsContainer(
22
            new Client(),
23
            $login,
24
            $password
25
        );
26
    }
27
28
    /**
29
     * @param string $login
30
     * @param string $password
31
     * @throws AuthenticationFailedException
32
     */
33
    protected static function checkCredentials($login, $password)
34
    {
35
        if (empty($login) || empty($password)) {
36
            throw new AuthenticationFailedException('You must provide login and password to send messages!');
37
        }
38
    }
39
40
    /**
41
     * @codeCoverageIgnore
42
     */
43
    private function __construct(){}
44
45
    /**
46
     * @codeCoverageIgnore
47
     */
48
    private function __clone(){}
49
}
50