| Total Complexity | 5 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class UsedClass |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var \BfwSql\UsedClass|null $instance UsedClass instance (Singleton) |
||
| 16 | */ |
||
| 17 | protected static $instance; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \BFW\Config $config The config instance for the current module |
||
| 21 | */ |
||
| 22 | protected $config; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * protected for Singleton pattern |
||
| 26 | * |
||
| 27 | * @param \BFW\Config $config The config instance for the current module |
||
| 28 | */ |
||
| 29 | protected function __construct(\BFW\Config $config) |
||
| 30 | { |
||
| 31 | $this->config = $config; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Get the UsedClass instance (Singleton pattern) |
||
| 36 | * |
||
| 37 | * @param \BFW\Config|null $config The config instance for the module |
||
| 38 | * |
||
| 39 | * @return \BfwSql\UsedClass |
||
| 40 | */ |
||
| 41 | public static function getInstance($config = null): \BfwSql\UsedClass |
||
| 42 | { |
||
| 43 | if (self::$instance === null) { |
||
| 44 | $class = get_called_class(); |
||
| 45 | self::$instance = new $class($config); |
||
| 46 | } |
||
| 47 | |||
| 48 | return self::$instance; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Getter accessor to config property |
||
| 53 | * |
||
| 54 | * @return \BFW\Config |
||
| 55 | */ |
||
| 56 | public function getConfig(): \BFW\Config |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Obtain the class name declared into config file "class.php" for a key |
||
| 63 | * |
||
| 64 | * @param string $classNameKey The class name key into the config file |
||
| 65 | * |
||
| 66 | * @return string |
||
| 67 | */ |
||
| 68 | public function obtainClassNameToUse(string $classNameKey): string |
||
| 71 | } |
||
| 72 | } |
||
| 73 |