mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-06-08 05:25:30 +02:00
33 lines
997 B
PHP
33 lines
997 B
PHP
<?php
|
|
|
|
namespace AdService;
|
|
|
|
class SiteConfigFactory
|
|
{
|
|
protected static $instances;
|
|
|
|
/**
|
|
* @param string $url
|
|
* @param bool $singleton en général, c'est la même config pour tous.
|
|
* @return \AdService\SiteConfig\AbstractSiteConfig
|
|
*/
|
|
public static function factory($url, $singleton=true)
|
|
{
|
|
if (false !== strpos($url, "leboncoin.fr")) {
|
|
$className = 'AdService\SiteConfig\Lbc';
|
|
} elseif (false !== strpos($url, "olx.ua")) {
|
|
$className = 'AdService\SiteConfig\Olx';
|
|
} elseif (false !== strpos($url, "www.seloger.com")) {
|
|
$className = 'AdService\SiteConfig\Seloger';
|
|
} else {
|
|
throw new Exception("No config found");
|
|
}
|
|
if ($singleton) {
|
|
if (!isset(self::$instances[$className])) {
|
|
self::$instances[$className] = new $className;
|
|
}
|
|
return self::$instances[$className];
|
|
}
|
|
return new $className;
|
|
}
|
|
} |