InvocableBeanCreator::create()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/*
3
 * Copyright (c) Manero Contributors. All rights reserved.
4
 *
5
 * Licensed under the MIT License. See LICENSE.md file in the
6
 * project root for full license information.
7
 */
8
9
namespace Manero\Creator;
10
11
class InvocableBeanCreator extends AbstractBeanCreator
12
{
13
    public function create() : void
14
    {
15
        $preAliasTemplate = '
16
            %indent%/**
17
            %indent% * @Bean({"aliases" = {';
18
19
        $postAliasTemplate = '
20
            %indent% * }})
21
            %indent% */
22
            %indent%public function get%classWithoutBackslashes%() : \%class%
23
            %indent%{
24
            %indent%    return new \%class%();
25
            %indent%}';
26
27
        $this->getWriter()->write($preAliasTemplate);
28
        $this->writeAliases();
29
        $this->getWriter()->write(str_replace(
30
            [
31
                '%class%',
32
                '%classWithoutBackslashes%',
33
            ],
34
            [
35
                $this->getClass(),
36
                str_replace('\\', '', $this->getClass()),
37
            ],
38
            $postAliasTemplate
39
        ));
40
    }
41
}
42