BoolPhpTypeSchemaResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A resolvePhpTypeSchema() 0 6 2
A supportsPhpType() 0 3 1
A getWeight() 0 3 1
1
<?php
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sunrise\Http\Router\OpenApi\PhpTypeSchemaResolver;
15
16
use Reflector;
17
use Sunrise\Http\Router\OpenApi\Exception\UnsupportedPhpTypeException;
18
use Sunrise\Http\Router\OpenApi\OpenApiPhpTypeSchemaResolverInterface;
19
use Sunrise\Http\Router\OpenApi\Type;
20
21
/**
22
 * @since 3.0.0
23
 */
24
final class BoolPhpTypeSchemaResolver implements OpenApiPhpTypeSchemaResolverInterface
25
{
26 3
    public function supportsPhpType(Type $phpType, Reflector $phpTypeHolder): bool
27
    {
28 3
        return $phpType->name === Type::PHP_TYPE_NAME_BOOL;
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 3
    public function resolvePhpTypeSchema(Type $phpType, Reflector $phpTypeHolder): array
35
    {
36 3
        $this->supportsPhpType($phpType, $phpTypeHolder) or throw new UnsupportedPhpTypeException();
37
38 3
        return [
39 3
            'type' => Type::OAS_TYPE_NAME_BOOLEAN,
40 3
        ];
41
    }
42
43 3
    public function getWeight(): int
44
    {
45 3
        return 0;
46
    }
47
}
48