| Total Complexity | 5 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 15 | class MapAsset extends AssetBundle |
||
| 16 | { |
||
| 17 | /** @var string */ |
||
| 18 | public static $mapName = 'world_mill_en'; |
||
| 19 | /** @var string */ |
||
| 20 | public $sourcePath = __DIR__ . '/src/maps'; |
||
| 21 | /** @var string|null */ |
||
| 22 | private $map; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @inheritDoc |
||
| 26 | */ |
||
| 27 | public function init() |
||
| 28 | { |
||
| 29 | parent::init(); |
||
| 30 | $maps = $this->getMapsArray(); |
||
| 31 | if (!empty($maps[self::$mapName])) { |
||
| 32 | $this->setMap($maps[self::$mapName]); |
||
| 33 | $this->js = [ |
||
| 34 | 'jquery-jvectormap-' . $this->getMap() . '.js' |
||
| 35 | ]; |
||
| 36 | } else { |
||
| 37 | throw new InvalidArgumentException(__class__ . ': Incorrect map name: "' . self::$mapName . '"'); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string[] |
||
| 43 | */ |
||
| 44 | public function getMapsArray() |
||
| 48 | ]; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param string $value |
||
| 53 | */ |
||
| 54 | public function setMap($value = '') |
||
| 55 | { |
||
| 56 | $this->map = $value; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string|null |
||
| 61 | */ |
||
| 62 | public function getMap() |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var string[] |
||
| 69 | */ |
||
| 70 | public $depends = [ |
||
| 71 | JVectorMapAsset::class, |
||
| 72 | ]; |
||
| 74 |