Code Duplication    Length = 26-26 lines in 2 locations

lib/WebMarketingROI/OptimizelyPHP/Service/v2/Pages.php 1 location

@@ 39-64 (lines=26) @@
36
     * @return Result
37
     * @throws Exception
38
     */
39
    public function listAll($projectId, $page=1, $perPage=25)
40
    {
41
        if ($page<0) {
42
            throw new Exception('Invalid page number passed');
43
        }
44
        
45
        if ($perPage<0) {
46
            throw new Exception('Invalid page size passed');
47
        }
48
        
49
        $result = $this->client->sendApiRequest('/pages', 
50
                array(
51
                    'project_id'=>$projectId,
52
                    'page'=>$page,
53
                    'per_page'=>$perPage
54
                ));
55
        
56
        $pages = array();
57
        foreach ($result->getDecodedJsonData() as $pageInfo) {
58
            $page = new Page($pageInfo);
59
            $pages[] = $page;
60
        }
61
        $result->setPayload($pages);
62
        
63
        return $result;
64
    }
65
    
66
    /**
67
     * Get metadata for a single Page

lib/WebMarketingROI/OptimizelyPHP/Service/v2/Audiences.php 1 location

@@ 39-64 (lines=26) @@
36
     * @return Result
37
     * @throws Exception
38
     */
39
    public function listAll($projectId, $page=1, $perPage=25)
40
    {
41
        if ($page<0) {
42
            throw new Exception('Invalid page number passed');
43
        }
44
        
45
        if ($perPage<0 || $perPage>100) {
46
            throw new Exception('Invalid page size passed');
47
        }
48
        
49
        $result = $this->client->sendApiRequest('/audiences', 
50
                array(
51
                    'project_id'=>$projectId,
52
                    'page'=>$page,
53
                    'per_page'=>$perPage
54
                ));
55
        
56
        $audiences = array();
57
        foreach ($result->getDecodedJsonData() as $audienceInfo) {
58
            $audience = new Audience($audienceInfo);
59
            $audiences[] = $audience;
60
        }
61
        $result->setPayload($audiences);
62
        
63
        return $result;
64
    }
65
    
66
    /**
67
     * Get metadata for a single Audience.