Passed
Branch master (72fde7)
by Observer
01:31
created

packages__updateCaption()   B

Complexity

Conditions 9
Paths 24

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 21
c 0
b 0
f 0
rs 8.0555
nc 24
nop 0
cc 9
1
<?php
2
3
namespace VoidEngine;
4
5
function packages__updateCaption ()
6
{
7
    $source  = VoidStudioAPI::getObjects ('addPackage')['Package__Source'];
0 ignored issues
show
Bug introduced by
The type VoidEngine\VoidStudioAPI was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
    $version = VoidStudioAPI::getObjects ('addPackage')['Package__Version'];
9
10
	$source = $source->selectedItem != 'github' ?
11
        $source->selectedItem .':' : '';
12
	
13
	$version = $version->text != 'latest' && $version->text ?
14
		'@'. $version->text : '';
15
	
16
    VoidStudioAPI::getObjects ('addPackage')['Package__Path']->caption = ($package = $source . VoidStudioAPI::getObjects ('addPackage')['Package__Author']->text .'/'. VoidStudioAPI::getObjects ('addPackage')['Package__Name']->text) . $version;
17
18
	VoidStudioAPI::getObjects ('addPackage')['Package__Add']->enabled = true;
19
	
20
	foreach (VoidStudioAPI::getObjects ('modules')['ModulesList__QeroPackages']->items->list as $line)
21
		if ((($pos = strrpos ($line, '@')) !== false && substr ($line, 0, $pos) == $package) || ($pos === false && $line == $package))
22
		{
23
			VoidStudioAPI::getObjects ('addPackage')['Package__Add']->enabled = false;
24
25
			break;
26
		}
27
}
28
29
function packages__update ()
30
{
31
    global $controller;
32
33
    $controller->manager->updateManager ();
34
35
    $modulesList = VoidStudioAPI::getObjects ('modules')['ModulesList'];
36
    $modulesList->items->clear ();
37
38
    $imageList = new ImageList;
39
    $qeroGroup = VoidStudioAPI::getObjects ('modules')['ModulesListGroup__QeroPackage'];
40
    $index = 0;
41
42
    foreach ($controller->manager->packages as $package)
43
    {
44
        $item = new ListViewItem ('  '. $package->name);
45
        $item->group      = $qeroGroup;
0 ignored issues
show
Bug Best Practice introduced by
The property group does not exist on VoidEngine\ListViewItem. Since you implemented __set, consider adding a @property annotation.
Loading history...
46
        $item->imageIndex = $index++;
0 ignored issues
show
Bug Best Practice introduced by
The property imageIndex does not exist on VoidEngine\ListViewItem. Since you implemented __set, consider adding a @property annotation.
Loading history...
47
48
        $imageList->images->add ((new Image)->loadFromFile (APP_DIR .'/components/icons/Library_16x.png'));
0 ignored issues
show
Bug Best Practice introduced by
The property images does not exist on VoidEngine\ImageList. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug introduced by
The method add() does not exist on VoidEngine\WFObject. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

48
        $imageList->images->/** @scrutinizer ignore-call */ 
49
                            add ((new Image)->loadFromFile (APP_DIR .'/components/icons/Library_16x.png'));
Loading history...
49
        $modulesList->items->add ($item);
50
    }
51
} 
52
53
$name = basenameNoExt (__FILE__);
54
55
$parser = new VLFParser (__DIR__. '/'. $name .'.vlf', [
56
    'strong_line_parser'            => false,
57
    'ignore_postobject_info'        => true,
58
    'ignore_unexpected_method_args' => true,
59
60
    'use_caching' => true,
61
    'debug_mode'  => false
62
]);
63
64
// file_put_contents ('SyntaxTree__'. $name .'.json', json_encode ($parser->tree, JSON_PRETTY_PRINT));
65
66
VoidStudioAPI::addObjects ($name, VLFInterpreter::run ($parser));
67