PluginInstaller::activate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the phpdish/plugin-installer package.
5
 *
6
 * (c) Slince <[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 PHPDish\PluginInstaller;
13
14
use Composer\Composer;
15
use Composer\IO\IOInterface;
16
use Composer\Plugin\PluginInterface;
17
use Composer\Util\Filesystem;
18
19
class PluginInstaller implements PluginInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    const PLUGIN_PATH = 'plugins';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function activate(Composer $composer, IOInterface $io)
30
    {
31
        (new Filesystem())->ensureDirectoryExists(static::PLUGIN_PATH);
32
33
        $repository = new ProxyRepository(static::PLUGIN_PATH, 2, $io, $composer->getConfig());
34
        $composer->getRepositoryManager()->addRepository($repository);
35
    }
36
}