Completed
Pull Request — master (#86)
by Sergey
02:55
created

Followable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 49
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A follow() 0 4 1
A unFollow() 0 4 1
A followCall() 0 6 1
getEntityIdName() 0 1 ?
getFollowUrl() 0 1 ?
getUnfFollowUrl() 0 1 ?
1
<?php
2
3
namespace seregazhuk\PinterestBot\Helpers\Providers\Traits;
4
5
trait Followable
6
{
7
    use ProviderTrait;
8
9
    /**
10
     * Follow user by user_id.
11
     *
12
     * @param $entityId
13
     *
14
     * @return bool
15
     */
16
    public function follow($entityId)
17
    {
18
        return $this->followCall($entityId, $this->getFollowUrl());
19
    }
20
21
    /**
22
     * UnFollow user by user_id.
23
     *
24
     * @param $entityId
25
     *
26
     * @return bool
27
     */
28
    public function unFollow($entityId)
29
    {
30
        return $this->followCall($entityId, $this->getUnfFollowUrl());
31
    }
32
33
    /**
34
     * Make api call for follow/unfollow a entity (user/board).
35
     *
36
     * @param int    $entityId
37
     * @param string $resourceUrl
38
     *
39
     * @return bool
40
     */
41
    protected function followCall($entityId, $resourceUrl)
42
    {
43
        $response = $this->getRequest()->followMethodCall($entityId, $this->getEntityIdName(), $resourceUrl);
44
45
        return $this->getResponse()->checkErrorInResponse($response);
46
    }
47
48
    abstract protected function getEntityIdName();
49
50
    abstract protected function getFollowUrl();
51
52
    abstract protected function getUnfFollowUrl();
53
}
54