Issues (6)

src/Objects/MinimumContractLengthObject.php (1 issue)

1
<?php
2
3
namespace ZpgRtf\Objects;
4
5
/**
6
 * The rental_term attribute can be specified with a minimum_contract_length object or, if the contract length is not
7
 * currently known, by an enum that roughly indicates its likely duration (e.g. "short_term").
8
 */
9 View Code Duplication
class MinimumContractLengthObject implements \JsonSerializable
0 ignored issues
show
This class 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...
10
{
11
    /** @var null|float */
12
    private $minimumLength;
13
14
    /**
15
     * Enum (days, weeks, months, years)
16
     *
17
     * @var null|string
18
     */
19
    private $units;
20
21
    /**
22
     * @return null|float
23
     */
24 2
    public function getMinimumLength()
25
    {
26 2
        return $this->minimumLength;
27
    }
28
29
    /**
30
     * @param float $minimumLength
31
     *
32
     * @return MinimumContractLengthObject
33
     */
34 1
    public function setMinimumLength(float $minimumLength): self
35
    {
36 1
        $this->minimumLength = $minimumLength;
37
38 1
        return $this;
39
    }
40
41
    /**
42
     * @return null|string
43
     */
44 2
    public function getUnits()
45
    {
46 2
        return $this->units;
47
    }
48
49
    /**
50
     * @param string $units
51
     *
52
     * @return MinimumContractLengthObject
53
     */
54 1
    public function setUnits(string $units): self
55
    {
56 1
        $this->units = $units;
57
58 1
        return $this;
59
    }
60
61
    /** {@inheritDoc} */
62 1
    public function jsonSerialize(): array
63
    {
64 1
        return array_filter([
65 1
            'minimum_length' => $this->getMinimumLength(),
66 1
            'units' => $this->getUnits(),
67
        ]);
68
    }
69
}
70