Completed
Push — master ( 51fcf2...214586 )
by Mathijs
04:31
created

test_manual.php ➔ myErrorHandler()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 7
c 1
b 0
f 1
nc 3
nop 4
dl 0
loc 13
rs 9.4285
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 2.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
error_reporting(E_ALL);
3
ini_set('display_errors', 1);
4
5
require 'vendor/autoload.php';
6
7
use GuzzleHttp\Client;
8
use mcorten87\rabbitmq_api\jobs\JobBaseCreateVirtualHost;
9
use mcorten87\rabbitmq_api\MqManagementConfig;
10
use mcorten87\rabbitmq_api\MqManagementFactory;
11
use mcorten87\rabbitmq_api\objects\Password;
12
use mcorten87\rabbitmq_api\objects\QueueArgument;
13
use mcorten87\rabbitmq_api\objects\QueueName;
14
use mcorten87\rabbitmq_api\objects\Url;
15
use mcorten87\rabbitmq_api\objects\User;
16
use mcorten87\rabbitmq_api\objects\VirtualHost;
17
use mcorten87\rabbitmq_api\services\MqManagermentService;
18
19
function myErrorHandler($errno, $errstr, $errfile, $errline)
0 ignored issues
show
Unused Code introduced by
The parameter $errfile 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...
Unused Code introduced by
The parameter $errline 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...
20
{
21
    if (!(error_reporting() & $errno)) {
22
        // This error code is not included in error_reporting
23
        return;
24
    }
25
26
    switch ($errno) {
27
        case 2: // Declaration of  errors <- they are equal to the base... stop complaining
28
            return strpos($errstr, 'Declaration of') !== false;
29
            break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
30
    }
31
}
32
33
// set to the user defined error handler
34
$old_error_handler = set_error_handler("myErrorHandler");
35
36
37
$url = new Url('http://192.168.33.11:15672/api/');
38
$user = new User('admin');
39
$password = new Password('admin');
40
41
$factory = new MqManagementFactory();
42
$config = new MqManagementConfig($user, $password, $url);
43
$mqManagerment = new MqManagermentService($factory, $config);
44
45
$client = new Client();
46
47
$jobService = $factory->getJobService();
48
49
//// list vhosts
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
50
//$job = $factory->getJobListVirtualHost();
51
//var_dump($jobService->execute($job)->getBody());
52
////
53
//// create vhost
54
//$job = $factory->getJobCreateVirtualHost(new VirtualHost('/foo/test'));
55
//var_dump($jobService->execute($job)->getBody());
56
////
57
////// list vhosts
58
//$job = $factory->getJobListVirtualHost();
59
//var_dump($jobService->execute($job)->getBody());
60
////
61
//$job = $factory->getJobListVirtualHost(new VirtualHost('/'));
62
//var_dump($jobService->execute($job)->getBody());
63
//
64
////
65
//// list specific vhost
66
//$job = $factory->getJobListVirtualHost(new VirtualHost('/foo/test'));
67
//var_dump($jobService->execute($job)->getBody());
68
//
69
//// delete vhost
70
//$job = $factory->getJobDeleteVirtualHost(new VirtualHost('/foo/test'));
71
//var_dump($jobService->execute($job)->getBody());
72
//
73
//// list vhosts
74
//$job = $factory->getJobListVirtualHost();
75
//var_dump($jobService->execute($job)->getBody());
76
////
77
////
78
////// queues
79
$job = $factory->getJobCreateQueue(new VirtualHost('/example/'),new QueueName('test'));
80
$job->setDurable(true);
81
$job->addArgument(new QueueArgument(QueueArgument::MAX_PRIORITY, 10));
82
var_dump($jobService->execute($job)->getBody());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($jobService->execute($job)->getBody()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
83
//
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
84
//$job = $factory->getJobListQueues();
85
//var_dump($jobService->execute($job)->getBody());
86
//
87
//$job = $factory->getJobListQueues(new VirtualHost('/example/'));
88
//var_dump($jobService->execute($job)->getBody());
89
//
90
//$job = $factory->getJobListQueue(new VirtualHost('/example/'),new QueueName('test'));
91
//var_dump($jobService->execute($job)->getBody());
92
////
93
////
94
////
95
//$job = $factory->getJobDeleteQueue(new VirtualHost('/example/'),new QueueName('test'));
96
//var_dump($jobService->execute($job)->getBody());
97
//
98
//
99
//$job = $factory->getJobListUser();
100
//var_dump($jobService->execute($job)->getBody());
101
//
102
//
103
//$job = $factory->getJobCreateUser(new User('mathijs'), new UserTag(UserTag::MANAGEMENT), new Password('test'));
104
//$job->addUserTag(new UserTag(UserTag::MONITORING));
105
//var_dump($jobService->execute($job)->getBody());
106
//
107
//$job = $factory->getJobListUser(new User('mathijs'));
108
//$userListResult = $jobService->execute($job);
109
//$userListResult = json_decode($userListResult->getBody());
110
//var_dump($userListResult);
111
//
112
//$job = $factory->getJobCreateUser(new User("mathijs"), new UserTag(UserTag::MANAGEMENT), null, new PasswordHash($userListResult->password_hash));
113
//$job->addUserTag(new UserTag(UserTag::MONITORING));
114
//$job->addUserTag(new UserTag(UserTag::ADMINISTRATOR));
115
//var_dump($jobService->execute($job)->getBody());
116
//
117
//$job = $factory->getJobListUser(new User('mathijs'));
118
//var_dump($jobService->execute($job)->getBody());
119
120
//$job = $factory->getJobListPermission();
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
121
//var_dump($jobService->execute($job)->getBody());
122
//
123
//$job = $factory->getJobListVirtualHostPermission(new VirtualHost('/example/'));
124
//var_dump($jobService->execute($job)->getBody());
125
//
126
//$job = $factory->getJobListUserPermission(new User('admin'));
127
//var_dump($jobService->execute($job)->getBody());
128
129
//$job = $factory->getJobCreatePermission(new VirtualHost('/'), new User('admin'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
130
//var_dump($jobService->execute($job)->getBody());
131
//
132
//$job = $factory->getJobDeletePermission(new VirtualHost('/'), new User('admin'));
133
//var_dump($jobService->execute($job)->getBody());
134