Code Duplication    Length = 25-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/Projects.php 1 location

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