Completed
Pull Request — 1.x (#139)
by Nana
02:20
created

JsonSchemaModule::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the BEAR.Resource package.
6
 *
7
 * @license http://opensource.org/licenses/MIT MIT
8
 */
9
namespace BEAR\Resource\Module;
10
11
use BEAR\Resource\Annotation\JsonSchema;
12
use BEAR\Resource\Interceptor\JsonSchemaInterceptor;
13
use BEAR\Resource\ResourceObject;
14
use Ray\Di\AbstractModule;
15
16
class JsonSchemaModule extends AbstractModule
17
{
18
    /**
19
     * Json-schema json file directory
20
     *
21
     * @var string
22
     */
23
    private $jsonSchemaDir;
24
25
    /**
26
     * Json-schema validator json file directory
27
     *
28
     * @var string
29
     */
30
    private $jsonValidateDir;
31
32 7
    public function __construct($jsonSchemaDir = '', $jsonValidateDir = '', AbstractModule $module = null)
33
    {
34 7
        $this->jsonSchemaDir = $jsonSchemaDir;
35 7
        $this->jsonValidateDir = $jsonValidateDir;
36 7
        parent::__construct($module);
0 ignored issues
show
Bug introduced by
It seems like $module defined by parameter $module on line 32 can also be of type object<Ray\Di\AbstractModule>; however, Ray\Di\AbstractModule::__construct() does only seem to accept null|object<self>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
37 7
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 7
    protected function configure()
43
    {
44 7
        $this->bind()->annotatedWith('json_schema_dir')->toInstance($this->jsonSchemaDir);
45 7
        $this->bind()->annotatedWith('json_validate_dir')->toInstance($this->jsonValidateDir);
46 7
        $this->bindInterceptor(
47 7
            $this->matcher->subclassesOf(ResourceObject::class),
48 7
            $this->matcher->annotatedWith(JsonSchema::class),
49 7
            [JsonSchemaInterceptor::class]
50
        );
51 7
    }
52
}
53