Completed
Push — dev ( e12847...805d11 )
by Darko
08:19 queued 01:40
created

ComposerScripts::postInstall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This program is free software: you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation, either version 3 of the License, or
6
 * (at your option) any later version.
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 * You should have received a copy of the GNU General Public License
12
 * along with this program (see LICENSE.txt in the base directory.  If
13
 * not, see:.
14
 *
15
 * @link      <http://www.gnu.org/licenses/>.
16
 * @author    niel
17
 * @copyright 2017 nZEDb
18
 */
19
20
namespace Blacklight\build;
21
22
use Composer\Script\Event;
23
use Illuminate\Foundation\Application;
24
25
class ComposerScripts
26
{
27
    /**
28
     * Handle the post-install Composer event.
29
     *
30
     * @param  \Composer\Script\Event  $event
31
     * @return void
32
     */
33
    public static function postInstall(Event $event)
34
    {
35
        require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
36
37
        static::clearCompiled();
38
    }
39
40
    /**
41
     * Handle the post-update Composer event.
42
     *
43
     * @param  \Composer\Script\Event  $event
44
     * @return void
45
     */
46
    public static function postUpdate(Event $event)
47
    {
48
        require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';
49
50
        static::clearCompiled();
51
    }
52
53
    /**
54
     * Clear the cached Laravel bootstrapping files.
55
     *
56
     * @return void
57
     */
58
    protected static function clearCompiled()
59
    {
60
        $nntmux = new Application(getcwd());
61
62
        if (file_exists($servicesPath = $nntmux->getCachedServicesPath())) {
63
            @unlink($servicesPath);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for unlink(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

63
            /** @scrutinizer ignore-unhandled */ @unlink($servicesPath);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
64
        }
65
    }
66
}
67