NamespaceAssembler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Descriptor\Builder\Reflector;
17
18
use phpDocumentor\Descriptor\Collection;
19
use phpDocumentor\Descriptor\DescriptorAbstract;
20
use phpDocumentor\Descriptor\NamespaceDescriptor;
21
use phpDocumentor\Reflection\Php\Namespace_;
22
23
final class NamespaceAssembler extends AssemblerAbstract
24
{
25
    /**
26
     * Creates a Descriptor from the provided data.
27
     *
28
     * @param Namespace_ $data
29
     *
30
     * @return DescriptorAbstract|Collection
31
     */
32
    public function create($data)
33
    {
34
        $descriptor = new NamespaceDescriptor();
35
        $descriptor->setName($data->getName());
36
        $descriptor->setFullyQualifiedStructuralElementName($data->getFqsen());
37
        $namespace = substr((string) $data->getFqsen(), 0, -strlen($data->getName()) - 1);
38
        $descriptor->setNamespace($namespace === '' ? '\\' : $namespace);
39
40
        return $descriptor;
41
    }
42
}
43