Skip to content

Commit

Permalink
Make sure we always have a stack (#134)
Browse files Browse the repository at this point in the history
* Make sure we always have a stack

* cs

* style update
  • Loading branch information
Nyholm authored Feb 23, 2017
1 parent 3384d0b commit de33f9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Collector/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getStacks()
}

/**
* @return Stack
* @return Stack|bool false if no current stack.
*/
public function getCurrentStack()
{
Expand Down
4 changes: 3 additions & 1 deletion Collector/ProfilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
{
$profile = new Profile($this->pluginName, $this->formatter->formatRequest($request));

$this->collector->getCurrentStack()->addProfile($profile);
if ($stack = $this->collector->getCurrentStack()) {
$stack->addProfile($profile);
}

return $this->plugin->handleRequest($request, $next, $first)->then(function (ResponseInterface $response) use ($profile) {
$profile->setResponse($this->formatter->formatResponse($response));
Expand Down

0 comments on commit de33f9c

Please sign in to comment.