The Query class
This class is a multiple values component class and manages the URL query component. It implementing the League\Url\Components\QueryInterface
.
This interface adds the following method:
QueryInterface::modify($data)
Updates the component data;
Example using the League\Url\Components\Query
object:
<?php
use League\Url\Components\Query;
$query = new Query('foo=bar');
$query['baz'] = 'troll';
$query['toto'] = 'le heros';
foreach ($query as $offset => $value) {
echo "$offset => $value".PHP_EOL;
}
// will echo
// foo => bar
// baz => troll
// toto => le%20heros
$query->modify(array('foo' => 'baz', 'toto' => null));
//by setting toto to null
//you remove the toto argument from the query_string
//you can get the same result by issuing
unset($query['toto']);
$found = $query->keys('troll');
//$found equals array(0 => 'baz')
echo count($query); //will return 2;