WeatherLib.php 708 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Heanup\Library;
  3. use Heanup\Library\WeatherAdapt\Weather;
  4. class WeatherLib
  5. {
  6. private static $instance;
  7. public function __construct()
  8. {
  9. }
  10. /**
  11. * @param $adapter
  12. * @return Weather
  13. */
  14. public static function getInstance($adapter)
  15. {
  16. if (!isset(self::$instance[md5($adapter)])) {
  17. try{
  18. $class = "Heanup\\Library\\WeatherAdapt\\".$adapter . "Adapter";
  19. $instance = new $class();
  20. self::$instance[md5($adapter)] = $instance;
  21. }catch (\Throwable $exception){
  22. var_dump($exception);
  23. }
  24. }
  25. return self::$instance[md5($adapter)];
  26. }
  27. }