Skip to content

Commit 7e00dc2

Browse files
authored
Merge pull request #27 from lucasmichot/feature/master/request-context-provider
RequestContextProvider: set docblocks and enforce Laravel style.
2 parents 520a8d4 + 315c83f commit 7e00dc2

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

src/RequestContextProvider.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,42 @@
88

99
class RequestContextProvider implements ContextProviderInterface
1010
{
11-
/** @var Request */
11+
/**
12+
* The current request.
13+
*
14+
* @var \Illuminate\Http\Request|null
15+
*/
1216
private $currentRequest;
1317

14-
/** @var VarCloner */
18+
/**
19+
* The variable cloner.
20+
*
21+
* @var \Symfony\Component\VarDumper\Cloner\VarCloner
22+
*/
1523
private $cloner;
1624

25+
/**
26+
* RequestContextProvider constructor.
27+
*
28+
* @param \Illuminate\Http\Request|null $currentRequest
29+
* @return void
30+
*/
1731
public function __construct(Request $currentRequest = null)
1832
{
1933
$this->currentRequest = $currentRequest;
20-
$this->cloner = new VarCloner();
34+
$this->cloner = new VarCloner;
2135
$this->cloner->setMaxItems(0);
2236
}
2337

38+
/**
39+
* Get the context.
40+
*
41+
* @return array|null
42+
*/
2443
public function getContext(): ?array
2544
{
26-
if (null === $this->currentRequest) {
27-
return null;
45+
if ($this->currentRequest === null) {
46+
return;
2847
}
2948

3049
$controller = null;
@@ -37,11 +56,11 @@ public function getContext(): ?array
3756
}
3857
}
3958

40-
return array(
59+
return [
4160
'uri' => $this->currentRequest->getUri(),
4261
'method' => $this->currentRequest->getMethod(),
4362
'controller' => $controller ? $this->cloner->cloneVar(class_basename($controller)) : $controller,
4463
'identifier' => spl_object_hash($this->currentRequest),
45-
);
64+
];
4665
}
4766
}

0 commit comments

Comments
 (0)