Passed
Push — master ( 79f846...b59e9f )
by Shiyu
02:12
created

STCors::cors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Setup CORS
4
 * User: moyo
5
 * Date: 2019-01-08
6
 * Time: 13:54
7
 */
8
9
namespace Carno\Web\Chips\Router;
10
11
use Carno\Web\Policy\CORS as Policy;
12
use Carno\Web\Policy\Inspector;
13
use Carno\Web\Policy\Rules\CORS as Rule;
14
15
trait STCors
16
{
17
    /**
18
     * @param string $prefix
19
     * @param string $origin
20
     * @return Rule
21
     */
22
    public function cors(string $prefix, string $origin = '*') : Rule
23
    {
24
        /**
25
         * @var Inspector $p
26
         */
27
28
        $p = $this->policy;
29
30
        $p->join(new Policy($prefix, $r = new Rule($origin)));
31
32
        return $r;
33
    }
34
}
35