for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BeyondCode\LaravelWebSockets\Server;
use Psr\Http\Message\RequestInterface;
class QueryParameters
{
/**
* The Request object.
*
* @var \Psr\Http\Message\RequestInterface
*/
protected $request;
public static function create(RequestInterface $request)
return new static($request);
}
* Initialize the class.
* @param \Psr\Http\Message\RequestInterface $request
* @return void
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
public function __construct(RequestInterface $request)
$this->request = $request;
* Get all query parameters.
* @return array
public function all(): array
$queryParameters = [];
parse_str($this->request->getUri()->getQuery(), $queryParameters);
return $queryParameters;
* Get a specific query parameter.
* @param string $name
* @return string
public function get(string $name): string
return $this->all()[$name] ?? '';
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.