LimitOrder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 62
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setValidPersistenceType() 0 12 2
A getPersistenceType() 0 4 1
A getPrice() 0 4 1
A getSize() 0 4 1
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