Completed
Push — master ( 0c5b7b...2c9e38 )
by Tom
13:30
created

ModuleNameStructure   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 61
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getShortModuleName() 0 4 1
A getFullModuleName() 0 4 1
A getVendorName() 0 4 1
A __toString() 0 4 1
1
<?php
2
/**
3
 * Copyright © 2016 netz98 new media GmbH. All rights reserved.
4
 * See COPYING.txt for license details.
5
 */
6
7
namespace N98\Magento\Command\Developer\Console\Structure;
8
9
class ModuleNameStructure
10
{
11
    /**
12
     * @var string
13
     */
14
    private $vendorName;
15
16
    /**
17
     * @var string
18
     */
19
    private $shortModuleName;
20
21
    /**
22
     * @param string $fullModuleName like Acme_Foo
23
     */
24
    public function __construct($fullModuleName)
25
    {
26
        $parts = explode('_', $fullModuleName);
27
28
        if (count($parts) !== 2) {
29
            throw new \InvalidArgumentException('Please specify a correct module name like Acme_Foo');
30
        }
31
32
        $this->vendorName = ucfirst($parts[0]);
33
        $this->shortModuleName = ucfirst($parts[1]);
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getShortModuleName()
40
    {
41
        return $this->shortModuleName;
42
    }
43
44
    /**
45
     * Returns the full module name in style Acme_Foo
46
     *
47
     * @return string
48
     */
49
    public function getFullModuleName()
50
    {
51
        return $this->vendorName . '_' . $this->shortModuleName;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getVendorName()
58
    {
59
        return $this->vendorName;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function __toString()
66
    {
67
        return $this->getFullModuleName();
68
    }
69
}
70