Completed
Push — master ( ca6e2c...137b9b )
by Pol
01:51
created

Subset::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace drupol\phpartition;
4
5
class Subset {
6
7
  /**
8
   * @var BasePartitionAlgorithm
9
   */
10
  protected $algo;
11
12
  /**
13
   * @var SubsetItem[]
14
   */
15
  protected $items;
16
17
  /**
18
   * @param \drupol\phpartition\SubsetItem $item
19
   */
20 4
  public function addItem(SubsetItem $item) {
21 4
    $this->items[] = $item;
22 4
  }
23
24
  /**
25
   * @return SubsetItem[]
26
   */
27 4
  public function getItems() {
28 4
    return (array) $this->items;
29
  }
30
31
  /**
32
   * @return array
33
   */
34 4
  public function getRawItems() {
35 4
    $data = array();
36
37 4
    foreach ($this->getItems() as $item) {
38 4
      $data[] = $item->getItem();
39 4
    }
40
41 4
    return $data;
42
  }
43
44
  /**
45
   * @return int
46
   */
47
  public function getWeight() {
48
    $sum = 0;
49
50
    foreach((array) $this->items as $item) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
51
      $sum += $item->getValue();
52
    }
53
54
    return $sum;
55
  }
56
57
  /**
58
   * @param \drupol\phpartition\BasePartitionAlgorithm $algo
59
   */
60 4
  public function setAlgo(BasePartitionAlgorithm $algo) {
61 4
    $this->algo = $algo;
62 4
  }
63
64
  /**
65
   * @return BasePartitionAlgorithm
66
   */
67 4
  public function getAlgo() {
68 4
    return $this->algo;
69
  }
70
71
}