LimitOrder::getPersistenceType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Betfair\Model\PlaceOrders;
4
5
6
use Betfair\Exception\ModelException;
7
8
class LimitOrder
9
{
10
11
    /**
12
     * @param float $size
13
     * @param float $price
14
     * @param string $persistenceType
15
     */
16
    public function __construct($size, $price, $persistenceType)
17
    {
18
        $this->size = $size;
19
        $this->price = $price;
20
        $this->setValidPersistenceType($persistenceType);
21
    }
22
23
    /** @var  float */
24
    private $size;
25
26
    /** @var  float */
27
    private $price;
28
29
    /** @var  PersistenceType */
30
    private $persistenceType;
31
32
33
    private function setValidPersistenceType($persistenceType)
34
    {
35
        if(!in_array($persistenceType, PersistenceType::toArray())) {
36
            throw new ModelException(
37
                sprintf("Not valid persistence type %s. Valid ones are %s",
38
                    $persistenceType,
39
                    implode(",", PersistenceType::toArray())
40
                ));
41
        }
42
43
        $this->persistenceType = $persistenceType;
44
    }
45
46
    /**
47
     * @return \Betfair\Model\PlaceOrders\PersistenceType
48
     */
49
    public function getPersistenceType()
50
    {
51
        return $this->persistenceType;
52
    }
53
54
    /**
55
     * @return float
56
     */
57
    public function getPrice()
58
    {
59
        return $this->price;
60
    }
61
62
    /**
63
     * @return float
64
     */
65
    public function getSize()
66
    {
67
        return $this->size;
68
    }
69
}
70