Completed
Push — master ( cc9e5c...67ffd6 )
by Sergey
13:28 queued 10:12
created

HasFollowers::getFollowersUrl()   A

Complexity

Conditions 2
Paths 2

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 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace seregazhuk\PinterestBot\Helpers\Providers\Traits;
4
5
use Iterator;
6
use seregazhuk\PinterestBot\Helpers\Pagination;
7
8
trait HasFollowers
9
{
10
    /**
11
     * Get followers.
12
     *
13
     * @param string $for
14
     * @param int $limit
15
     *
16
     * @return Iterator
17
     */
18
    public function followers($for, $limit = 0)
19
    {
20
        return $this->getFollowData(
21
            [$this->getFollowersFor() => $for], $this->getFollowersUrl(), $limit
22
        );
23
    }
24
    
25
    /**
26
     * @param array  $data
27
     * @param string $resourceUrl
28
     * @param int $limit
29
     *
30
     * @return Iterator
31
     */
32
    public function getFollowData($data, $resourceUrl, $limit = 0)
33
    {
34
        $requestData = array_merge([$data, $resourceUrl]);
35
36
        return (new Pagination($this))->paginateOver('getPaginatedData', $requestData, $limit);
37
    }
38
39
    protected function getFollowersUrl()
40
    {
41
        return property_exists($this, 'followersUrl') ? $this->followersUrl : '';
0 ignored issues
show
Bug introduced by
The property followersUrl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
42
    }
43
44
    protected function getFollowersFor()
45
    {
46
        return property_exists($this, 'followersFor') ? $this->followersFor : '';
0 ignored issues
show
Bug introduced by
The property followersFor does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
47
    }
48
}
49