fromNative() public static method

Returns a new Dictionary object
public static fromNative ( ) : self
return self
Beispiel #1
0
 public function testFromNative()
 {
     $constructedArray = \SplFixedArray::fromArray(array(new KeyValuePair(new StringLiteral('0'), new StringLiteral('zero')), new KeyValuePair(new StringLiteral('1'), new StringLiteral('one')), new KeyValuePair(new StringLiteral('2'), new StringLiteral('two'))));
     $fromNativeArray = \SplFixedArray::fromArray(array('zero', 'one', 'two'));
     $constructedDictionary = new Dictionary($constructedArray);
     $fromNativeDictionary = Dictionary::fromNative($fromNativeArray);
     $this->assertTrue($constructedDictionary->sameValueAs($fromNativeDictionary));
 }
 public function testToDictionary()
 {
     $query = new QueryString('?foo=bar&array[]=one&array[]=two');
     $dictionary = $query->toDictionary();
     $this->assertInstanceOf('ValueObjects\\Structure\\Dictionary', $dictionary);
     $array = array('foo' => 'bar', 'array' => array('one', 'two'));
     $expectedDictionary = Dictionary::fromNative($array);
     $this->assertTrue($expectedDictionary->sameValueAs($dictionary));
 }
Beispiel #3
0
 /**
  * Returns a Dictionary structured representation of the query string
  *
  * @return Dictionary
  */
 public function toDictionary()
 {
     $value = \ltrim($this->toNative(), '?');
     \parse_str($value, $data);
     return Dictionary::fromNative($data);
 }