Completed
Pull Request — master (#768)
by Antoine
10:44 queued 07:23
created

ScriptHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A installSwaggerUi() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ApiPlatform\Core\Composer;
13
14
use Composer\Script\Event;
15
use Symfony\Component\Filesystem\Filesystem;
16
use Symfony\Component\Finder\Finder;
17
18
class ScriptHandler
19
{
20
21
    protected static $destination = '/src/Bridge/Symfony/Bundle/Resources/public/swagger-ui/dist';
22
    protected static $source = '/vendor/swagger-api/swagger-ui/dist';
23
24
    /**
25
     * Copy swagger ui to the correct directory.
26
     *
27
     * @parm Event $event
28
     */
29
    public static function installSwaggerUi(Event $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        $fs = new Filesystem();
32
        $finder = new Finder();
33
        $cwd = getcwd();
34
35
        foreach ($finder->in($cwd.self::$source) as $file) {
36
            $destination = $cwd.self::$destination.'/'.$file->getRelativePathname();
37
            if ($file->isDir()) {
38
                $fs->mkdir($destination);
39
                continue;
40
            }
41
42
            $fs->copy($file->getRealPath(), $destination, true);
43
        }
44
    }
45
}
46