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

STCors   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A cors() 0 11 1
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