Completed
Pull Request — master (#20)
by Alexander
10:01
created

SmsIntel::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.9332
cc 1
nc 1
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
47
    /**
48
     * @codeCoverageIgnore
49
     */
50
    private function __clone()
51
    {
52
    }
53
}
54