public function __construct($config, $url = null) { if (!$config instanceof Config\Config) { $config = new Config\Config($config); } $this->url = new Url($url, $config); $this->config = $this->url->getConfig(); }
public function __construct($config, $url = null) { if ($config instanceof Config\Config) { $config = $config; } else { $config = new Config\Config($config); } $this->url = $url = new Url($url); $configKey = $url->getUrlKey(); $defaultConfig = $config->thumbers->current(); $defaultKey = $config->thumbers->key(); if (isset($config->thumbers->{$configKey})) { if ($defaultKey == $configKey) { $this->config = $config->thumbers->{$configKey}; } else { $this->config = $defaultConfig->merge($config->thumbers->{$configKey}); } } else { throw new Exception\InvalidArgumentException(sprintf('No config found by key %s', $configKey)); } }
public function testIsValid() { $url = new Url(''); $this->assertEquals(false, $url->isValid()); $url = new Url('foo'); $this->assertEquals(false, $url->isValid()); $url = new Url('http://localhost'); $this->assertEquals(false, $url->isValid()); $url = new Url('http://localhost/thumb/test.jpg'); $this->assertEquals(false, $url->isValid()); $url = new Url('http://localhost/thumb/d/test'); $this->assertEquals(false, $url->isValid()); $url = new Url('http://localhost/thumb/d/test.jpg'); $this->assertEquals(true, $url->isValid()); }