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

Accept::authorize()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6.0359

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 17
ccs 9
cts 10
cp 0.9
rs 8.8571
cc 6
eloc 9
nc 4
nop 2
crap 6.0359
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