Completed
Push — master ( af83f4...b4262b )
by Sergey
03:54 queued 01:20
created

Bot::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace seregazhuk\PinterestBot;
4
5
use seregazhuk\PinterestBot\Api\Providers\Boards;
6
use seregazhuk\PinterestBot\Api\Providers\Conversations;
7
use seregazhuk\PinterestBot\Api\Providers\Interests;
8
use seregazhuk\PinterestBot\Api\Providers\Keywords;
9
use seregazhuk\PinterestBot\Api\Providers\News;
10
use seregazhuk\PinterestBot\Api\Providers\Pinners;
11
use seregazhuk\PinterestBot\Api\Providers\Pins;
12
use seregazhuk\PinterestBot\Api\Providers\Provider;
13
use seregazhuk\PinterestBot\Api\Providers\User;
14
use seregazhuk\PinterestBot\Contracts\ProvidersContainerInterface;
15
16
/**
17
 * Class Bot.
18
 *
19
 *
20
 * @property Pins $pins 
21
 * @property News $news
22
 * @property User $user
23
 * @property Boards $boards
24
 * @property Pinners $pinners
25
 * @property Keywords $keywords
26
 * @property Interests $interests
27
 * @property Conversations $conversations
28
 */
29
class Bot
30
{
31
    /**
32
     * @var ProvidersContainerInterface
33
     */
34
    private $providersContainer;
35
36
    /**
37
     * @param ProvidersContainerInterface $providersContainer
38
     */
39
    public function __construct(ProvidersContainerInterface $providersContainer)
40
    {
41
        $this->providersContainer = $providersContainer;
42
    }
43
44
    /**
45
     * Proxy method to pinners login.
46
     *
47
     * @param string $username
48
     * @param string $password
49
     *
50
     * @return bool
51
     */
52
    public function login($username, $password)
53
    {
54
        return $this->pinners->login($username, $password);
55
    }
56
57
    /**
58
     * Proxy method to pinners logout.
59
     */
60
    public function logout()
61
    {
62
        return $this->pinners->logout();
63
    }
64
65
66
    /**
67
     * Magic method to access different providers.
68
     *
69
     * @param string $provider
70
     *
71
     * @return Provider
72
     */
73
    public function __get($provider)
74
    {
75
        return $this->providersContainer->getProvider($provider);
76
    }
77
78
    /**
79
     * Proxy method to Request object.
80
     *
81
     * @return array
82
     */
83
    public function getLastError()
84
    {
85
        return $this->providersContainer->getResponse()->getLastError();
86
    }
87
88
    public function isLoggedIn()
89
    {
90
        return $this->providersContainer->getRequest()->isLoggedIn();
91
    }
92
}
93