Completed
Pull Request — master (#111)
by Sergey
03:15
created

Bot::isLoggedIn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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
     * Magic method to access different providers.
59
     *
60
     * @param string $provider
61
     *
62
     * @return Provider
63
     */
64
    public function __get($provider)
65
    {
66
        return $this->providersContainer->getProvider($provider);
67
    }
68
69
    /**
70
     * Proxy method to Request object.
71
     *
72
     * @return array
73
     */
74
    public function getLastError()
75
    {
76
        return $this->providersContainer->getResponse()->getLastError();
77
    }
78
79
    public function isLoggedIn()
80
    {
81
        return $this->providersContainer->getRequest()->isLoggedIn();
82
    }
83
}
84