Issues (6)

src/Objects/PricePerUnitAreaObject.php (1 issue)

1
<?php
2
3
namespace ZpgRtf\Objects;
4
5
/**
6
 * This object describes a price which is provided as a function of floor area.
7
 */
8 View Code Duplication
class PricePerUnitAreaObject 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...
9
{
10
    /** @var null|float */
11
    private $price;
12
13
    /**
14
     * Enum (sq_feet, sq_yards, sq_metres, acres, hectares)
15
     *
16
     * @var null|string
17
     */
18
    private $units;
19
20
    /**
21
     * @return null|float
22
     */
23 2
    public function getPrice()
24
    {
25 2
        return $this->price;
26
    }
27
28
    /**
29
     * @param float $price
30
     *
31
     * @return PricePerUnitAreaObject
32
     */
33 1
    public function setPrice(float $price): self
34
    {
35 1
        $this->price = $price;
36
37 1
        return $this;
38
    }
39
40
    /**
41
     * @return null|string
42
     */
43 2
    public function getUnits()
44
    {
45 2
        return $this->units;
46
    }
47
48
    /**
49
     * @param string $units
50
     *
51
     * @return PricePerUnitAreaObject
52
     */
53 1
    public function setUnits(string $units): self
54
    {
55 1
        $this->units = $units;
56
57 1
        return $this;
58
    }
59
60
    /** {@inheritDoc} */
61 1
    public function jsonSerialize(): array
62
    {
63 1
        return array_filter([
64 1
            'price' => $this->getPrice(),
65 1
            'units' => $this->getUnits(),
66
        ]);
67
    }
68
}
69