Passed
Push — master ( dc6772...7a0f4a )
by Harm
05:47
created

ScriptHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 24
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A linkAssets() 0 15 1
1
<?php
2
3
namespace HarmBandstra\SwaggerUiBundle\Composer;
4
5
use Composer\Script\Event;
6
use Symfony\Component\Filesystem\Filesystem;
7
use Symfony\Component\Finder\Finder;
8
9
class ScriptHandler
10
{
11
    const SWAGGER_UI_DIST_DIR = 'swagger-api/swagger-ui/dist';
12
    const BUNDLE_PUBLIC_DIR = 'harmbandstra/swagger-ui-bundle/src/Resources/public';
13
14
    /**
15
     * @param Event $event
16
     */
17 1
    public static function linkAssets(Event $event)
18
    {
19 1
        $filesystem = new Filesystem();
20 1
        $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
21
22 1
        $source = sprintf('%s/%s', $vendorDir, self::SWAGGER_UI_DIST_DIR);
23 1
        $target = sprintf('%s/%s', $vendorDir, self::BUNDLE_PUBLIC_DIR);
24
25 1
        $filesIterator = new Finder();
26 1
        $filesIterator->files()->in($source)->notName('*.map');
27
28 1
        $filesystem->mirror($source, $target, $filesIterator, ['override' => true]);
29
30 1
        $event->getIO()->write('Linked SwaggerUI assets.');
31 1
    }
32
}
33