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

ModuleNameStructure::getFullModuleName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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