Esempio n. 1
0
 /**
  * Return the URI for this header
  *
  * @return string
  */
 public function getUri()
 {
     if ($this->uri instanceof HttpUri) {
         return $this->uri->toString();
     }
     return $this->uri;
 }
Esempio n. 2
0
 /**
  * @param string $uri
  *
  * @return ImageUri
  */
 public function setUri($uri)
 {
     $this->uri = new Http($uri);
     if (!$this->uri->isAbsolute()) {
         throw new \InvalidArgumentException('Invalid image URL: ' . $this->uri->toString());
     }
     return $this;
 }
Esempio n. 3
0
 protected function buildUrl($url)
 {
     if (!$this->apiKey) {
         throw new MissingAPIKeyException('Missing the API key.  Please either call setApiKey(), set the API key as a dependency parameter, or create a Magium/Mail/GeneratorConfiguration.php file to set the API key');
     }
     $uri = new Http($url);
     $uri->setQuery(['key' => $this->apiKey]);
     return $uri->toString();
 }
Esempio n. 4
0
 public function testGetPortDoesntModifyUrlHttps()
 {
     $origUri = 'https://www.example.com/foo';
     $uri = new HttpUri($origUri);
     $uri->getPort();
     $this->assertEquals($origUri, $uri->toString());
 }
Esempio n. 5
0
 /**
  * Test that normalizing an HTTP URL removes the port depending on scheme
  *
  * @param string $orig
  * @param string $expected
  * @dataProvider portNormalizationTestsProvider
  */
 public function testNormalizationRemovesPort($orig, $expected)
 {
     $uri = new HttpUri($orig);
     $uri->normalize();
     $this->assertEquals($expected, $uri->toString());
 }
 /**
  * @param Http $httpUri
  * @param int $offset
  * @param int $limit
  * @return array
  */
 protected function partiallyRequest(Http $httpUri, $offset, $limit)
 {
     $query = $httpUri->getQueryAsArray();
     $query['start'] = $offset;
     $query['count'] = $limit;
     $httpUri->setQuery($query);
     $elements = $this->mapper->fetchAll($httpUri->toString());
     $entityName = $this->classMetadata->getName();
     $entities = array();
     foreach ($elements as $element) {
         $hydrator = new EntityHydrator($this->classMetadata);
         $entities[] = $hydrator->hydrate($element, new $entityName());
     }
     return $entities;
 }