AnnotationRegister::register()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2018 Yuuki Takezawa
17
 */
18
19
namespace Ytake\Lom;
20
21
use Doctrine\Common\Annotations\AnnotationReader;
22
use Doctrine\Common\Annotations\AnnotationRegistry;
23
use Doctrine\Common\Annotations\IndexedReader;
24
25
/**
26
 * Class AnnotationRegister.
27
 *
28
 * @author  yuuki.takezawa<[email protected]>
29
 * @license http://opensource.org/licenses/MIT MIT
30
 */
31
class AnnotationRegister
32
{
33
    /**
34
     * annotations register.
35
     *
36
     * @return $this
37
     */
38
    final public function register(): self
39
    {
40
        $iterator = new \DirectoryIterator(__DIR__.'/Meta');
41
        foreach ($iterator as $file) {
42
            if ($file->isFile()) {
43
                $name = $file->getPathInfo()->getPathname().'/'.$file->getFilename();
44
                AnnotationRegistry::registerFile($name);
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...egistry::registerFile() has been deprecated with message: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
45
            }
46
        }
47
48
        return $this;
49
    }
50
51
    /**
52
     * @throws \Doctrine\Common\Annotations\AnnotationException
53
     *
54
     * @return IndexedReader
55
     */
56
    public function getReader(): IndexedReader
57
    {
58
        return new IndexedReader(new AnnotationReader());
59
    }
60
}
61