CropFactory.php
1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace backend\components\croppers;
use Yii;
class CropFactory
{
private static $instance;
private $crops = [];
private function __construct() {
$this->init();
}
private function init() {
$this->crops[] = new EconomixCrop();
$this->crops[] = new GoldenGardenFlowersCrop();
$this->crops[] = new GoldenGardenVegiesCrop();
$this->crops[] = new GoldenGardenGiantCrop();
$this->crops[] = new UkrSeedsNovikGiantCrop();
$this->crops[] = new UkrSeedsNovikMiniCrop();
$this->crops[] = new UkrSeedsNovikVegiesCrop();
$this->crops[] = new UkrSeedsNovikFlowersCrop();
$this->crops[] = new UkrSeedsTekVegiesCrop();
$this->crops[] = new UkrSeedsFloraMiniCrop();
$this->crops[] = new UkrSeedsFloraVegiesCrop();
}
public function getCrop($crop_id) {
return $this->crops[$crop_id];
}
public function findMinHeight() {
$min = PHP_INT_MAX;
foreach ($this->crops as $crop) {
$height = $crop->getConstants()['HEIGHT'];
$min = $min > $height ? $height : $min;
}
return $min;
}
public static function getInstance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
}