@@ -13,21 +13,24 @@ use PhpGpio\Gpio;
13
13
14
14
// Am i using php-cli?
15
15
if ('cli ' != PHP_SAPI ) {
16
- throw new \Exception ("This script must be run using php-cli " );
16
+ echo $ msg = "This script must be run using php-cli " ;
17
+ throw new \Exception ($ msg );
17
18
}
18
19
19
20
// Am I a sudoer or the root user?
20
21
if ('root ' !== $ _SERVER ['USER ' ] || empty ($ _SERVER ['SUDO_USER ' ])) {
21
- throw new \Exception ("Please run this script as root: sudo phpunit or sudo ./phpunit.phar ; please check the README file " );
22
+ echo $ msg = "Please run this script as root, using sudo -t ; please check the README file " ;
23
+ throw new \Exception ($ msg );
22
24
}
23
25
24
- // Am I using only 2 integer arugments ?
26
+ // Am I using only 2 integer arguments ?
25
27
if (
26
28
!(3 === $ argc )
27
29
|| (0 >= (int )($ argv [1 ]))
28
30
|| (0 >= (int )($ argv [2 ]))
29
31
) {
30
- throw new \Exception ("This script expect 2 positive integer arguments: please check the README file " );
32
+ echo $ msg = "This script expect 2 positive integer arguments: please check the README file " ;
33
+ throw new \Exception ($ msg );
31
34
}
32
35
33
36
@@ -36,7 +39,8 @@ $sleeper = (int)$argv[2];
36
39
$ gpio = new GPIO ();
37
40
38
41
if (!in_array ($ pin , $ gpio ->getHackablePins ())){
39
- throw new \InvalidArgumentException ("$ pin is not a hackable gpio pin number " );
42
+ echo $ msg = "$ pin is not a hackable gpio pin number " ;
43
+ throw new \InvalidArgumentException ($ msg );
40
44
}
41
45
42
46
$ gpio ->setup ($ pin , "out " );
0 commit comments