Install   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A postUpdate() 0 5 1
A postAutoloadDump() 0 10 1
A postPackageInstall() 0 7 1
A warmCache() 0 12 1
1
<?php
2
3
namespace Codexshaper\WooCommerce\PHP;
4
5
use Composer\Script\Event;
6
use Composer\Installer\PackageEvent;
7
8
class Install
9
{
10
    public static function postUpdate(Event $event)
11
    {
12
        $composer = $event->getComposer();
0 ignored issues
show
Unused Code introduced by
$composer is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
13
        // do stuff
14
    }
15
16
    public static function postAutoloadDump(Event $event)
17
    {
18
        $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
19
        require $vendorDir . '/autoload.php';
20
21
        mkdir($vendorDir.'/basir', 0700);
22
        mkdir($vendorDir.'/../test', 0700);
23
24
        // some_function_from_an_autoloaded_file();
25
    }
26
27
    public static function postPackageInstall(PackageEvent $event)
28
    {
29
        $installedPackage = $event->getOperation()->getPackage();
30
        // do stuff
31
32
        var_dump($installedPackage);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($installedPackage); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
33
    }
34
35
    public static function warmCache(Event $event)
36
    {
37
        // make cache toasty
38
        $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
39
        mkdir($vendorDir.'/basir', 0700);
40
        mkdir($vendorDir.'/../test', 0700);
41
42
        $content = "some text here";
43
        $fp = fopen("myText.txt","wb");
44
        fwrite($fp,$content);
45
        fclose($fp);
46
    }
47
}
48