Completed
Push — master ( f77348...ad6f80 )
by Sergey
03:41
created

Bot   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 4
c 7
b 0
f 0
lcom 2
cbo 3
dl 0
loc 48
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\News;
7
use seregazhuk\PinterestBot\Api\Providers\Pins;
8
use seregazhuk\PinterestBot\Api\Providers\Boards;
9
use seregazhuk\PinterestBot\Api\Providers\Pinners;
10
use seregazhuk\PinterestBot\Api\Providers\Provider;
11
use seregazhuk\PinterestBot\Api\Providers\Interests;
12
use seregazhuk\PinterestBot\Api\Providers\Conversations;
13
use seregazhuk\PinterestBot\Api\Providers\User;
14
use seregazhuk\PinterestBot\Contracts\ProvidersContainerInterface;
15
16
/**
17
 * Class Bot
18
 *
19
 * @package Pinterest
20
 *
21
 * @property Pins $pins
22
 * @property News $news
23
 * @property User $user
24
 * @property Boards $boards
25
 * @property Pinners $pinners
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
     * @return Provider
62
     */
63
    public function __get($provider)
64
    {
65
        return $this->providersContainer->getProvider($provider);
66
    }
67
68
    /**
69
     * Proxy method to Request object
70
     * @return array
71
     */
72
    public function getLastError()
73
    {
74
        return $this->providersContainer->getResponse()->getLastError();
75
    }
76
}
77