Passed
Pull Request — master (#35)
by
unknown
02:53
created

VideosRequestParameters   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 29.73 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 11
loc 37
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrder() 11 11 2
A setPublicationState() 0 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace MovingImage\Client\VMPro\Entity;
4
5
use MovingImage\Client\VMPro\Util\AccessorTrait;
6
7
/**
8
 * Class VideosRequestParameters.
9
 *
10
 * @method int getVideoId()
11
 * @method VideosRequestParameters setVideoId(int $videoId)
12
 * @method int getChannelId()
13
 * @method VideosRequestParameters setChannelId(int $channelId)
14
 * @method int getOffset()
15
 * @method VideosRequestParameters setOffset(int $offset)
16
 * @method int getLimit()
17
 * @method VideosRequestParameters setLimit(int $limit)
18
 * @method string getOrder()
19
 * @method string getOrderProperty()
20
 * @method VideosRequestParameters setOrderProperty(string $orderProperty)
21
 * @method string getSearchTerm()
22
 * @method VideosRequestParameters setSearchTerm(string $searchTerm)
23
 * @method bool isIncludeCustomMetadata()
24
 * @method VideosRequestParameters setIncludeCustomMetadata(bool $includeCustomMetadata)
25
 * @method string getCustomMetadataField()
26
 * @method VideosRequestParameters setCustomMetadataField(int $customMetadataField)
27
 * @method string getSearchInField()
28
 * @method VideosRequestParameters setSearchInField(string $searchInField)
29
 * @method string getPublicationState()
30
 * @method bool isIncludeKeywords()
31
 * @method VideosRequestParameters setIncludeKeywords(bool $includeKeywords)
32
 * @method VideosRequestParameters setIncludeChannelAssignments(bool $includeChannels)
33
 * @method bool isIncludeSubChannels()
34
 * @method VideosRequestParameters setIncludeSubChannels(bool $includeSubChannels)
35
 *
36
 * @author Omid Rad <[email protected]>
37
 */
38
class VideosRequestParameters
39
{
40
    use AccessorTrait;
41
42
    /**
43
     * @param string $order
44
     *
45
     * @return VideosRequestParameters
46
     */
47 View Code Duplication
    public function setOrder($order)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $pool = ['asc', 'desc'];
50
51
        // Silently ignore wrong values
52
        if (in_array($order, $pool)) {
53
            $this->container['order'] = $order;
54
        }
55
56
        return $this;
57
    }
58
59
    /**
60
     * @param string $publicationState
61
     *
62
     * @return VideosRequestParameters
63
     */
64
    public function setPublicationState($publicationState)
65
    {
66
        $pool = ['published', 'not_published', 'all'];
67
68
        if (in_array($publicationState, $pool)) {
69
            $this->container['publication_state'] = $publicationState;
70
        }
71
72
        return $this;
73
    }
74
}
75