Skip to content

Commit

Permalink
changed contextualinterface and contextualtrait to accept objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Jacome committed Sep 20, 2018
1 parent 021b7ba commit b502805
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ContextualInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ interface ContextualInterface
/**
* Set the context for the logger
*
* @param array $context
* @param mixed $context
*
* @return mixed
*/
public function setContext(array $context);
public function setContext($context);

/**
* Retrieve the context of this class
Expand Down
11 changes: 10 additions & 1 deletion Helper/ContextualTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace KoderHut\OnelogBundle\Helper;

use KoderHut\OnelogBundle\ContextualInterface;


/**
* Trait ContextualTrait
*
Expand All @@ -17,8 +20,14 @@ trait ContextualTrait
/**
* @inheritdoc
*/
public function setContext(array $context): self
public function setContext($context): self
{
if (is_object($context) && $context instanceof ContextualInterface) {
$context = $context->getContext();
} else if (is_object($context)) {
throw new \InvalidArgumentException();
}

$this->contextualData = $context;

return $this;
Expand Down

0 comments on commit b502805

Please sign in to comment.