Completed
Pull Request — dev (#11)
by
unknown
05:12 queued 01:17
created

RouterHeaderPlugin::afterHandlerSelected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Vectorface\SnappyRouter\Plugin\HttpHeader;
4
5
use Vectorface\SnappyRouter\Handler\AbstractHandler;
6
use Vectorface\SnappyRouter\Plugin\AbstractPlugin;
7
8
/**
9
 * A plugin that adds an HTTP header to indicate the route passed through the service router.
10
 * @copyright Copyright (c) 2014, VectorFace, Inc.
11
 * @author Dan Bruce <[email protected]>
12
 */
13
class RouterHeaderPlugin extends AbstractPlugin
14
{
15
    /**
16
     * Invoked directly after the router decides which handler will be used.
17
     * @param AbstractHandler $handler The handler selected by the router.
18
     */
19 1
    public function afterHandlerSelected(AbstractHandler $handler)
20
    {
21 1
        parent::afterhandlerSelected($handler);
22 1
        @header('X-Router: SnappyRouter');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
23 1
    }
24
}
25