Completed
Push — master ( f63129...3a8a63 )
by Sergey
03:49
created

FollowTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
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 46
rs 10

6 Methods

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