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

SmsIntel::checkCredentials()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 3
nc 2
nop 2
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