Completed
Pull Request — master (#32)
by Sergey
03:28
created

Bot   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
c 5
b 0
f 0
lcom 2
cbo 3
dl 0
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A login() 0 4 1
A __get() 0 4 1
A getLastError() 0 4 1
1
<?php
2
3
namespace seregazhuk\PinterestBot;
4
5
use LogicException;
6
use seregazhuk\PinterestBot\Api\Providers\Pins;
7
use seregazhuk\PinterestBot\Api\Providers\Boards;
8
use seregazhuk\PinterestBot\Api\Providers\Pinners;
9
use seregazhuk\PinterestBot\Api\Providers\Provider;
10
use seregazhuk\PinterestBot\Api\Providers\Interests;
11
use seregazhuk\PinterestBot\Api\Providers\Conversations;
12
use seregazhuk\PinterestBot\Contracts\ProvidersContainerInterface;
13
14
/**
15
 * Class Bot
16
 *
17
 * @package Pinterest
18
 * @property string        $username
19
 * @property string        $password
20
 * @property Pinners       $pinners
21
 * @property Pins          $pins
22
 * @property Boards        $boards
23
 * @property Interests     $interests
24
 * @property Conversations $conversations
25
 */
26
class Bot
27
{
28
    /**
29
     * @var ProvidersContainerInterface
30
     */
31
    private $providersContainer;
32
33
    public function __construct(ProvidersContainerInterface $providersContainer)
34
    {
35
        $this->providersContainer = $providersContainer;
36
    }
37
38
    /**
39
     * Proxy method to pinners login
40
     * @param string $username
41
     * @param string $password
42
     * @return bool
43
     */
44
    public function login($username, $password)
45
    {
46
        return $this->pinners->login($username, $password);
47
    }
48
49
    /**
50
     * @param string $provider
51
     * @return Provider
52
     */
53
    public function __get($provider)
54
    {
55
        return $this->providersContainer->getProvider($provider);
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getLastError()
62
    {
63
        return $this->providersContainer->getResponse()->getLastError();
64
    }
65
}