コード例 #1
0
 /**
  * Execute the filter command
  *
  * @param  InputInterface  $input  Input object
  * @param  OutputInterface $output Output object
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $col = new \Expose\FilterCollection();
     $col->load();
     $filters = $col->getFilterData();
     $id = $input->getOption('id');
     if ($id !== false) {
         $idList = explode(',', $id);
         foreach ($idList as $id) {
             if (array_key_exists($id, $filters)) {
                 $detail = "[" . $id . "] " . $filters[$id]->getDescription() . "\n";
                 $detail .= "\tRule: " . $filters[$id]->getRule() . "\n";
                 $detail .= "\tTags: " . implode(', ', $filters[$id]->getTags()) . "\n";
                 $detail .= "\tImpact: " . $filters[$id]->getImpact() . "\n";
                 $output->writeLn($detail);
             } else {
                 $output->writeLn('Filter ID ' . $id . ' not found!');
             }
         }
         return;
     }
     foreach ($filters as $filter) {
         echo $filter->getId() . ': ' . $filter->getDescription() . "\n";
     }
     return;
 }
コード例 #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $filters = new \Expose\FilterCollection();
     $filters->load();
     $logger = App::make('log');
     $manager = new \Expose\Manager($filters, $logger);
     $manager->run($request->input());
     Log::info(sprintf("Logging results from Expose %d", $manager->getImpact()));
     return $next($request);
 }
コード例 #3
0
 /**
  * Get the Manager instance (or make a new one)
  *
  * @return \Expose\Manager instance
  */
 protected function getManager()
 {
     if ($this->manager === null) {
         $filters = new \Expose\FilterCollection();
         $filters->load();
         $manager = new \Expose\Manager($filters);
         $this->manager = $manager;
     } else {
         $manager = $this->manager;
     }
     return $manager;
 }
コード例 #4
0
ファイル: ManagerTest.php プロジェクト: rendler-denis/expose
 public function testThresholdHigherThenImpact()
 {
     $filter = new \Expose\Filter();
     $filter->setImpact(5);
     $collection = new \Expose\FilterCollection();
     $collection->addFilter($filter);
     $manager_mock = $this->getMockBuilder('\\Expose\\Manager')->setConstructorArgs(array($collection, new \Expose\MockLogger()))->setMethods(array('sendNotification'))->getMock();
     $manager_mock->expects($this->never())->method('sendNotification');
     $manager_mock->setThreshold(100);
     $manager_mock->run(array('test' => 'test'), false, true);
 }