Skip to content

Commit

Permalink
check inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Dec 1, 2015
1 parent a319674 commit 066d89e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Detector.php
Expand Up @@ -156,6 +156,10 @@ public function getProcessor($processorName)
$processorClassName = $this->getProcessorClassName($processorName);
$processor = new $processorClassName($this);

if (!($processor instanceof ProcessorInterface)) {
throw new \Exception('Processor must inherit ProcessorInterface');
}

// configure processor
$configuratorCallable = $this->processorDeclarationList->get($processorName);
if($configuratorCallable && is_callable($configuratorCallable)) {
Expand Down
5 changes: 5 additions & 0 deletions src/Processor/RequestRateProcessor.php
Expand Up @@ -3,6 +3,7 @@
namespace Sokil\FraudDetector\Processor;

use \Sokil\FraudDetector\AbstractProcessor;
use Sokil\FraudDetector\Processor\RequestRate\Collector\CollectorInterface;

class RequestRateProcessor extends AbstractProcessor
{
Expand Down Expand Up @@ -50,6 +51,10 @@ public function setCollector($type, $configuratorCallable = null)
$this->timeInterval
);

if (!($this->collector instanceof CollectorInterface)) {
throw new \Exception('Collector must inherit CollectorInterface');
}

// configure
if(is_callable($configuratorCallable)) {
call_user_func($configuratorCallable, $this->collector);
Expand Down

0 comments on commit 066d89e

Please sign in to comment.