Exemple #1
0
 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();
 }
Exemple #2
0
 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));
     }
 }
Exemple #3
0
 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());
 }