1 | <?php |
||
9 | class Normalizer implements Preprocessor |
||
10 | { |
||
11 | const NORM_L1 = 1; |
||
12 | const NORM_L2 = 2; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | private $norm; |
||
18 | |||
19 | /** |
||
20 | * @param int $norm |
||
21 | * |
||
22 | * @throws NormalizerException |
||
23 | */ |
||
24 | public function __construct(int $norm = self::NORM_L2) |
||
32 | |||
33 | /** |
||
34 | * @param array $samples |
||
35 | */ |
||
36 | public function fit(array $samples) |
||
40 | |||
41 | /** |
||
42 | * @param array $samples |
||
43 | */ |
||
44 | public function transform(array &$samples) |
||
51 | |||
52 | /** |
||
53 | * @param array $sample |
||
54 | */ |
||
55 | private function normalizeL1(array &$sample) |
||
71 | |||
72 | /** |
||
73 | * @param array $sample |
||
74 | */ |
||
75 | private function normalizeL2(array &$sample) |
||
91 | } |
||
92 |
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.