for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* League.Uri (http://uri.thephpleague.com)
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @copyright 2013-2015 Ignace Nyamagana Butera
* @license https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
* @version 4.2.0
* @link https://github.com/thephpleague/uri/
*/
namespace League\Uri\Components;
use League\Uri\Interfaces\Fragment as FragmentInterface;
* Value object representing a URI fragment component.
* @since 1.0.0
class Fragment extends AbstractComponent implements FragmentInterface
{
* @inheritdoc
protected static $reservedCharactersRegex = "\!\$&'\(\)\*\+,;\=\:\/@\?";
* Preserve the delimiter
* @var string
protected $preserveDelimiter = false;
* new instance
* @param string|null $data the component value
public function __construct($data = null)
if ($data !== null) {
$this->preserveDelimiter = true;
$preserveDelimiter
string
true
boolean
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
$this->init($data);
}
public static function __set_state(array $properties)
$component = new static($properties['data']);
$component->preserveDelimiter = $properties['preserveDelimiter'];
return $component;
public function __debugInfo()
return ['fragment' => $this->__toString()];
* Returns the instance string representation
* with its optional URI delimiters
* @return string
public function getUriComponent()
$component = $this->__toString();
if ($this->preserveDelimiter) {
return FragmentInterface::DELIMITER.$component;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.