Completed
Push — master ( ed9860...cc2227 )
by Sergey
05:31 queued 02:42
created

HasFollowers::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 4
1
<?php
2
3
namespace seregazhuk\PinterestBot\Helpers\Providers\Traits;
4
5
use Iterator;
6
use seregazhuk\PinterestBot\Api\Request;
7
use seregazhuk\PinterestBot\Helpers\Pagination;
8
9
trait HasFollowers
10
{
11
    use ProviderTrait;
12
13
    /**
14
     * @param array  $data
15
     * @param string $url
16
     * @param string $sourceUrl
17
     * @param array  $bookmarks
18
     *
19
     * @return array
20
     */
21
    public function getData($data, $url, $sourceUrl, $bookmarks = [])
22
    {
23
        $data['options'] = $data;
24
        $response = $this->getRequest()->exec($url.'?'.Request::createQuery($data, $sourceUrl, $bookmarks));
25
26
        return $this->getResponse()->getPaginationData($response);
27
    }
28
29
    /**
30
     * @param array  $data
31
     * @param string $resourceUrl
32
     * @param string $sourceUrl
33
     * @param int    $batchesLimit
34
     *
35
     * @return Iterator
36
     */
37
    public function getFollowData($data, $resourceUrl, $sourceUrl, $batchesLimit = 0)
38
    {
39
        $requestData = array_merge([$data, $resourceUrl, $sourceUrl]);
40
41
        return Pagination::getPaginatedData([$this, 'getData'], $requestData, $batchesLimit);
42
    }
43
}
44