InvocableBeanCreator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 26 1
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