Passed
Branch master (d58387)
by Sergey
03:31
created

FollowersTrait::getFollowData()   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 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
use seregazhuk\PinterestBot\Helpers\UrlHelper;
9
10
trait FollowersTrait
11
{
12
    use ProviderTrait;
13
14
    /**
15
     * @param array $data
16
     * @param string $url
17
     * @param string $sourceUrl
18
     * @param array $bookmarks
19
     * @return array
20
     */
21
    public function getData($data, $url, $sourceUrl, $bookmarks = [])
22
    {
23
        $data['options'] = $data;
24
        $get = Request::createRequestData($data, $sourceUrl, $bookmarks);
25
        $getString = UrlHelper::buildRequestString($get);
26
        $response = $this->getRequest()->exec($url . '?' . $getString);
27
28
        return $this->getResponse()->getPaginationData($response);
29
    }
30
31
    /**
32
     * @param array $data
33
     * @param string $resourceUrl
34
     * @param string $sourceUrl
35
     * @param int $batchesLimit
36
     * @return Iterator
37
     */
38
    public function getFollowData($data, $resourceUrl, $sourceUrl, $batchesLimit = 0)
39
    {
40
        $requestData = array_merge([$data, $resourceUrl, $sourceUrl]);
41
42
        return Pagination::getPaginatedData([$this, 'getData'], $requestData, $batchesLimit);
43
    }
44
45
}