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

Followable::followCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
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