Code Duplication    Length = 19-20 lines in 2 locations

src/LTDBeget/sphinx/configurator/configurationEntities/base/Definition.php 2 locations

@@ 127-146 (lines=20) @@
124
     * @throws InvalidArgumentException
125
     * @throws LogicException
126
     */
127
    private function defineName(string $name)
128
    {
129
        $name = trim($name);
130
131
        if (empty($name)) {
132
            throw new SectionException("Name of section {$this->getType()} can't be empty.");
133
        }
134
135
        if(! $this->isValidName($name)) {
136
            throw new SectionException('Name of definition must contains only A-Za-z and _ symbols');
137
        }
138
139
        foreach ($this->getSelfTypeIterator() as $definition) {
140
            if($definition->getName() === $name) {
141
                throw new SectionException("Duplicate name {$name} found in {$this->getType()} section");
142
            }
143
        }
144
145
        $this->name = $name;
146
    }
147
148
    /**
149
     * @param string $inheritance
@@ 154-172 (lines=19) @@
151
     * @throws LogicException
152
     * @throws InvalidArgumentException
153
     */
154
    private function defineInheritance(string $inheritance)
155
    {
156
        $inheritance = trim($inheritance);
157
158
        if(! $this->isValidName($inheritance)) {
159
            throw new SectionException('Inheritance of definition must contains only A-Za-z and _ symbols');
160
        }
161
162
        foreach ($this->getSelfTypeIterator() as $definition) {
163
            if($definition->getName() === $inheritance) {
164
                $this->inheritance = $definition;
165
            }
166
        }
167
168
        if (! $this->isHasInheritance()) {
169
            throw new SectionException("Inheritance with name {$inheritance} of section {$this->getType()} doesn't exists in configuration");
170
        }
171
172
    }
173
174
    /**
175
     * @param $name