Completed
Push — master ( d34cec...faecd8 )
by Augusto
02:22
created

Accept   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 6
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 22
ccs 9
cts 10
cp 0.9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B authorize() 0 17 6
1
<?php
2
/*
3
 * This file is part of the Respect\Rest package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Respect\Rest\Routines;
10
11
/** Handles mime type content negotiation */
12
class Accept extends AbstractAccept
13
{
14
    const ACCEPT_HEADER = 'HTTP_ACCEPT';
15
16 17
    protected function authorize($requested, $provided)
17
    {
18 17
        if ($requested === $provided || $requested === '*/*') {
19 11
            return $provided;
20
        }
21
22 6
        if (false !== strpos($requested, '/')) {
23 6
            list($requestedA, $requestedB) = explode('/', $requested);
24 6
            list($providedA,) = explode('/', $provided);
25
26 6
            if ($providedA === $requestedA && $requestedB === '*') {
27
                return $providedA;
28
            }
29 6
        }
30
31 6
        return parent::authorize($requested, $provided);
32
    }
33
}
34