Completed
Push — dev ( 070006...d86ef5 )
by Андрей
02:18
created

ModuleOptions::getEntitySeparator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Doctrine\Options;
7
8
use Zend\Stdlib\AbstractOptions;
9
use Nnx\ModuleOptions\ModuleOptionsInterface;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Nnx\Doctrine\Options\ModuleOptionsInterface.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
use Nnx\Doctrine\Options\ModuleOptionsInterface as CurrentModuleOptionsInterface;
11
12
/**
13
 * Class ModuleOptions
14
 *
15
 * @package Nnx\Doctrine\Options
16
 */
17
class ModuleOptions extends AbstractOptions implements ModuleOptionsInterface, CurrentModuleOptionsInterface
18
{
19
    /**
20
     * Строка, используемая как разделитель в полном имени класса сущности(или интерфейса), которая разделяет неймспейс
21
     * на две части: 1) Нейсмпейс в котором расположенные все сущности 2) Постфикс указывающий на кокнетную сущность.
22
     * Например \Nnx\Doctrine\PhpUnit\TestData\EntityAutoResolve\TestModule1\Entity\TestEntity\TestEntityInterface
23
     * 1) Разделителем будет \Entity\
24
     * 2) Неймспейс в котром расположены все сущности будет \Nnx\Doctrine\PhpUnit\TestData\EntityAutoResolve\TestModule1\Entity\
25
     * 3) Постфикс указывающий на кокнетную сущность будет TestEntity\TestEntityInterface
26
     *
27
     * @var string
28
     */
29
    protected $entitySeparator;
30
31
    /**
32
     * Паттерн по которому из имени интерфейса можно получить строку, являющеюся заготовкой для формирования имени сущности
33
     *
34
     * @var string
35
     */
36
    protected $entityBodyNamePattern;
37
38
    /**
39
     * Строка которая добавляется перед  заготовкой имени сущности полученной в результате
40
     * примерения @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
41
     *
42
     * @var string
43
     */
44
    protected $entityNamePrefix;
45
46
    /**
47
     * Строка которая добавляется после заготовки имени сущности полученной в результате примерения
48
     * @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
49
     *
50
     * @var string
51
     */
52
    protected $entityNamePostfix;
53
54
55
    /**
56
     * Строка, используемая как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
57
     *
58
     * @return string
59
     */
60
    public function getEntitySeparator()
61
    {
62
        return $this->entitySeparator;
63
    }
64
65
    /**
66
     * Устанавливает строку используемую как разделитель в полном имени класса сущности (@see \Nnx\Doctrine\Options\ModuleOptions::$entitySeparator)
67
     *
68
     * @param string $entitySeparator
69
     *
70
     * @return $this
71
     */
72
    public function setEntitySeparator($entitySeparator)
73
    {
74
        $this->entitySeparator = $entitySeparator;
75
76
        return $this;
77
    }
78
79
    /**
80
     * @inheritdoc
81
     *
82
     * @return string
83
     */
84
    public function getEntityBodyNamePattern()
85
    {
86
        return $this->entityBodyNamePattern;
87
    }
88
89
    /**
90
     * Устанавливает паттерн по которому из имени интерфейса можно получить строку,
91
     * являющеюся заготовкой для формирования имени сущности
92
     *
93
     * @param string $entityBodyNamePattern
94
     *
95
     * @return $this
96
     */
97
    public function setEntityBodyNamePattern($entityBodyNamePattern)
98
    {
99
        $this->entityBodyNamePattern = $entityBodyNamePattern;
100
101
        return $this;
102
    }
103
104
    /**
105
     * @inheritdoc
106
     *
107
     * @return string
108
     */
109
    public function getEntityNamePrefix()
110
    {
111
        return $this->entityNamePrefix;
112
    }
113
114
    /**
115
     * Устанавливает строку которая добавляется перед  заготовкой именем сущности полученной в результате
116
     * примерения @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
117
     *
118
     * @param string $entityNamePrefix
119
     *
120
     * @return $this
121
     */
122
    public function setEntityNamePrefix($entityNamePrefix)
123
    {
124
        $this->entityNamePrefix = $entityNamePrefix;
125
126
        return $this;
127
    }
128
129
    /**
130
     * @inheritdoc
131
     *
132
     * @return string
133
     */
134
    public function getEntityNamePostfix()
135
    {
136
        return $this->entityNamePostfix;
137
    }
138
139
    /**
140
     * Устанавливает строку которая добавляется после заготовки имени сущности полученной в результате примерения
141
     * @see \Nnx\Doctrine\Options\ModuleOptions::$entityBodyNamePattern к имени интерфейса.
142
     *
143
     * @param string $entityNamePostfix
144
     *
145
     * @return $this
146
     */
147
    public function setEntityNamePostfix($entityNamePostfix)
148
    {
149
        $this->entityNamePostfix = $entityNamePostfix;
150
151
        return $this;
152
    }
153
}
154