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

FollowersTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 9 1
A getFollowData() 0 6 1
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
}