Code Duplication    Length = 25-26 lines in 4 locations

lib/WebMarketingROI/OptimizelyPHP/Service/v2/Attributes.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('/attributes', 
50
                array(
51
                    'project_id'=>$projectId,
52
                    'page'=>$page,
53
                    'per_page'=>$perPage
54
                ));
55
        
56
        $attributes = array();
57
        foreach ($result->getDecodedJsonData() as $attributeInfo) {
58
            $attribute = new Attribute($attributeInfo);
59
            $attributes[] = $attribute;
60
        }
61
        $result->setPayload($attributes);
62
        
63
        return $result;
64
    }
65
    
66
    /**
67
     * Get Attribute by ID

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.

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

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