/** * Constructor. * * @param string $url The URL to create the resource from. * @param \pdyn\cache\CacheInterface $cache A caching object. * @param \pdyn\httpclient\HttpClientInterface $httpclient An HttpClientInterface instance. * @param int $ttl How long the cached information will stay valid, in seconds. * @param array $initialdata Initial local object cache information. This is NOT cached, so that should be done elsewhere * if using this parameter. * @return HttpResource An HttpResource object, or one of it's decendents. */ public function __construct($url, \pdyn\cache\CacheInterface $cache, \pdyn\httpclient\HttpClientInterface $httpclient, $ttl = 7200, array $initialdata = array()) { $url = \pdyn\datatype\Url::normalize($url); // Basic data + dependencies. $this->url = $url; $this->cache = $cache; $this->httpclient = $httpclient; $this->ttl = $ttl; // Cache data. $this->cachekey = sha1($this->url); $this->cacheexpiry = time() + $this->ttl; // Initial data. $this->data = $initialdata; }
/** * Test normalize method. * * @dataProvider dataprovider_normalize * @param string $test Test text. * @param string $expected Expected output. */ public function test_normalize($test, $expected) { $actual = \pdyn\datatype\Url::normalize($test); $this->assertEquals($expected, $actual); }