Completed
Push — master ( bb645e...4d0389 )
by Jaap
11:40 queued 08:50
created

RemoveSourcecode::execute()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
nc 4
nop 1
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 6
rs 9.1111
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of phpDocumentor.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @link https://phpdoc.org
12
 */
13
14
namespace phpDocumentor\Compiler\Pass;
15
16
use phpDocumentor\Compiler\CompilerPassInterface;
17
use phpDocumentor\Descriptor\ApiSetDescriptor;
18
use phpDocumentor\Descriptor\ProjectDescriptor;
19
20
final class RemoveSourcecode implements CompilerPassInterface
21
{
22
    public const COMPILER_PRIORITY = 2000;
23
24 1
    public function getDescription() : string
25
    {
26 1
        return 'Removing sourcecode from file descriptors';
27
    }
28
29 2
    public function execute(ProjectDescriptor $project) : void
30
    {
31 2
        foreach ($project->getVersions() as $version) {
32 2
            foreach ($version->getDocumentationSets() as $documentationSet) {
33 2
                if (!$documentationSet instanceof ApiSetDescriptor ||
34 2
                    $documentationSet->getSettings()['include-source']
35
                ) {
36 1
                    continue;
37
                }
38
39 1
                foreach ($project->getFiles() as $file) {
40 1
                    $file->setSource(null);
41
                }
42
            }
43
        }
44 2
    }
45
}
46