| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 13 | class MediaModels |
||
| 14 | { |
||
| 15 | protected static $models = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return MediaRecords |
||
| 19 | */ |
||
| 20 | static public function records() |
||
| 21 | { |
||
| 22 | return static::getModels('records', MediaRecords::class); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return MediaProperties |
||
| 27 | */ |
||
| 28 | static public function properties() |
||
| 29 | { |
||
| 30 | return static::getModels('properties', MediaProperties::class); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $type |
||
| 35 | * @param string $default |
||
| 36 | * @return mixed|\Nip\Records\AbstractModels\RecordManager |
||
| 37 | */ |
||
| 38 | static protected function getModels($type, $default) |
||
| 39 | { |
||
| 40 | if (!isset(static::$models[$type])) { |
||
| 41 | $modelManager = static::getConfigVar($type, $default); |
||
| 42 | return static::$models[$type] = ModelLocator::get($modelManager); |
||
| 43 | } |
||
| 44 | |||
| 45 | return static::$models[$type]; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $type |
||
| 50 | * @param null|string $default |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | static protected function getConfigVar($type, $default = null) |
||
| 64 | } |
||
| 65 | } |
||
| 66 |