Completed
Push — master ( b0612a...e62e65 )
by Pol
06:37
created

Greedy::getSubsetWeight()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace drupol\phpartition\Algorithm;
4
5
use drupol\phpartition\BasePartitionAlgorithm;
6
use drupol\phpartition\PartitionAlgorithmInterface;
7
8
/**
9
 * Class Greedy.
10
 *
11
 * @package drupol\phpartition\Algorithm
12
 */
13
class Greedy extends BasePartitionAlgorithm implements PartitionAlgorithmInterface {
14
15
  /**
16
   * {@inheritdoc}
17
   */
18 2
  public function getResult() {
19
    // The greedy algorithm needs the input data to be sorted (desc).
20 2
    $this->getDataPartition()->sortByValue('DESC');
21 2
    return parent::getResult();
22
  }
23
24
}
25