Completed
Push — master ( 9e17e8...bb6fe9 )
by Fatih
01:21
created
src/AWSCustomMetric/Plugin/DiskUsage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@
 block discarded – undo
33 33
         $osName = $this->diObj->getCommandRunner()->getReturnValue();
34 34
         switch ($osName) {
35 35
             case 'Darwin':
36
-                $this->diObj->getCommandRunner()->execute('/bin/df -k -l ' . $this->mountPoint . " | awk '{print $8}'");
36
+                $this->diObj->getCommandRunner()->execute('/bin/df -k -l '.$this->mountPoint." | awk '{print $8}'");
37 37
                 break;
38 38
             case 'Linux':
39
-                $this->diObj->getCommandRunner()->execute('/bin/df -k -l ' . $this->mountPoint . " | awk '{print $5}'");
39
+                $this->diObj->getCommandRunner()->execute('/bin/df -k -l '.$this->mountPoint." | awk '{print $5}'");
40 40
                 break;
41 41
             default:
42
-                $this->diObj->getCommandRunner()->execute('/bin/df -k -l ' . $this->mountPoint . " | awk '{print $5}'");
42
+                $this->diObj->getCommandRunner()->execute('/bin/df -k -l '.$this->mountPoint." | awk '{print $5}'");
43 43
                 break;
44 44
         }
45 45
 
46 46
         $diskUtil = intval($this->diObj->getCommandRunner()->getReturnValue());
47 47
         if ($diskUtil>0) {
48
-            return [ $this->createNewMetric('DiskUsage', 'Percent', $diskUtil) ];
48
+            return [$this->createNewMetric('DiskUsage', 'Percent', $diskUtil)];
49 49
         } else {
50 50
             return null;
51 51
         }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Plugin/HttpCheck.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function __construct(DI $diObj, $namespace = null, $cronExpression = '')
32 32
     {
33
-        self::$equalsFunc = function ($string, $needle) {
33
+        self::$equalsFunc = function($string, $needle) {
34 34
             return $string==$needle;
35 35
         };
36 36
 
37
-        self::$containsFunc = function ($string, $needle) {
37
+        self::$containsFunc = function($string, $needle) {
38 38
             return strpos($string, $needle)!==false;
39 39
         };
40 40
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function addHeader($header, $val)
97 97
     {
98
-        $this->headers[ $header ] = $val;
98
+        $this->headers[$header] = $val;
99 99
     }
100 100
 
101 101
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function removeHeader($header)
105 105
     {
106
-        unset($this->headers[ $header ]);
106
+        unset($this->headers[$header]);
107 107
     }
108 108
 
109 109
     /**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function setBodyToCheck($bodyToCheck, $checkFunc = null)
170 170
     {
171 171
         $this->bodyToCheck   = $bodyToCheck;
172
-        $this->bodyCheckFunc = $checkFunc?$checkFunc:self::$equalsFunc;
172
+        $this->bodyCheckFunc = $checkFunc ? $checkFunc : self::$equalsFunc;
173 173
     }
174 174
 
175 175
     /**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         if (!$this->url || !$this->method) {
234 234
             if ($this->diObj->getLogger()) {
235 235
                 $this->diObj->getLogger()->error(
236
-                    (!$this->url)?'Url is not defined to check!':'Method is not defined to check!'
236
+                    (!$this->url) ? 'Url is not defined to check!' : 'Method is not defined to check!'
237 237
                 );
238 238
             }
239 239
             return false;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 'http_errors' => false,
246 246
                 'connect_timeout' => $this->timeout,
247 247
                 'timeout' => $this->timeout,
248
-                'on_stats' => function (TransferStats $stats) {
248
+                'on_stats' => function(TransferStats $stats) {
249 249
                     $this->responseTime = $stats->getTransferTime();
250 250
                 }
251 251
             ]);
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             }
260 260
         } catch (\Exception $e) {
261 261
             if ($this->diObj->getLogger()) {
262
-                $this->diObj->getLogger()->error('Guzzle Http client thrown exception! Msg: ' . $e->getMessage());
262
+                $this->diObj->getLogger()->error('Guzzle Http client thrown exception! Msg: '.$e->getMessage());
263 263
             }
264 264
             return [$this->createNewMetric('HttpCheckFail', 'Count', 1)];
265 265
         }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Plugin/ServicePortCheck.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function getServiceName()
23 23
     {
24
-        return $this->serviceName?:$this->server . ':' . $this->port;
24
+        return $this->serviceName ?: $this->server.':'.$this->port;
25 25
     }
26 26
 
27 27
     /**
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
             if ($fp) {
75 75
                 fclose($fp);
76 76
                 return [
77
-                    $this->createNewMetric($this->getServiceName() . 'CheckFail', 'Count', 0)
77
+                    $this->createNewMetric($this->getServiceName().'CheckFail', 'Count', 0)
78 78
                 ];
79 79
             }
80 80
         } catch (\Exception $e) {
81 81
             if ($this->diObj->getLogger()) {
82 82
                 $this->diObj->getLogger()->error(
83 83
                     'Service port check thrown exception!'
84
-                    .' Service:' . $this->getServiceName() . ', Msg: ' . $e->getMessage()
84
+                    .' Service:'.$this->getServiceName().', Msg: '.$e->getMessage()
85 85
                 );
86 86
             }
87 87
         }
88
-        return [$this->createNewMetric($this->getServiceName() . 'CheckFail', 'Count', 1)];
88
+        return [$this->createNewMetric($this->getServiceName().'CheckFail', 'Count', 1)];
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Plugin/MemcachedCheck.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
             }
103 103
         } catch (\Exception $e) {
104 104
             if ($this->diObj->getLogger()) {
105
-                $this->diObj->getLogger()->error('Memcached client thrown exception! ExcpMsg: ' . $e->getMessage());
105
+                $this->diObj->getLogger()->error('Memcached client thrown exception! ExcpMsg: '.$e->getMessage());
106 106
             }
107 107
             return [
108 108
                 $this->createNewMetric('MemcachedCheckFail', 'Count', 1)
Please login to merge, or discard this patch.
src/AWSCustomMetric/Sender.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -237,11 +237,11 @@
 block discarded – undo
237 237
                 'MetricName' => $metric->getName(),
238 238
                 'Unit' => $metric->getUnit(),
239 239
                 'Value' => $metric->getValue(),
240
-                'Timestamp' => gmdate('Y-m-d') . 'T' . gmdate('H:i:s') . 'Z'
240
+                'Timestamp' => gmdate('Y-m-d').'T'.gmdate('H:i:s').'Z'
241 241
             ];
242 242
         }
243 243
         $this->cloudWatchClient->putMetricData([
244
-            'Namespace'  => $namespace?:$this->getNamespace(),
244
+            'Namespace'  => $namespace ?: $this->getNamespace(),
245 245
             'MetricData' => $metricData
246 246
         ]);
247 247
     }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Logger/DefaultLogger.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
 {
7 7
     public function debug($msg)
8 8
     {
9
-        echo "[".date('Y-m-d H:i:s')."][DEBUG] " . $msg . "\n";
9
+        echo "[".date('Y-m-d H:i:s')."][DEBUG] ".$msg."\n";
10 10
     }
11 11
 
12 12
     public function info($msg)
13 13
     {
14
-        echo "[".date('Y-m-d H:i:s')."][INFO] " . $msg . "\n";
14
+        echo "[".date('Y-m-d H:i:s')."][INFO] ".$msg."\n";
15 15
     }
16 16
 
17 17
     public function error($msg)
18 18
     {
19
-        echo "[".date('Y-m-d H:i:s')."][ERROR] " . $msg . "\n";
19
+        echo "[".date('Y-m-d H:i:s')."][ERROR] ".$msg."\n";
20 20
     }
21 21
 }
Please login to merge, or discard this patch.
src/AWSCustomMetric/DI.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
         $action  = substr($name, 0, 3);
29 29
         $objName = substr($name, 3);
30 30
         if ($action=='set') {
31
-            $this->objList[ $objName ] = $arguments[0];
31
+            $this->objList[$objName] = $arguments[0];
32 32
             return true;
33 33
         } else {
34
-            return isset($this->objList[ $objName ])?$this->objList[ $objName ]:null;
34
+            return isset($this->objList[$objName]) ? $this->objList[$objName] : null;
35 35
         }
36 36
     }
37 37
 }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Plugin/RedisCheck.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     }
20 20
 
21 21
     /**
22
-     * @return mixed
22
+     * @return string
23 23
      */
24 24
     public function getServer()
25 25
     {
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
     private function getServerPortArgs()
54 54
     {
55
-        return '-h ' . $this->getServer() . ' -p ' . $this->getPort();
55
+        return '-h '.$this->getServer().' -p '.$this->getPort();
56 56
     }
57 57
 
58 58
     private function getRedisCliCmd()
59 59
     {
60
-        return '/usr/bin/redis-cli ' . $this->getServerPortArgs();
60
+        return '/usr/bin/redis-cli '.$this->getServerPortArgs();
61 61
     }
62 62
 
63 63
     /**
@@ -82,28 +82,28 @@  discard block
 block discarded – undo
82 82
     private function findKeys()
83 83
     {
84 84
         try {
85
-            $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw dbsize');
85
+            $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd().' --raw dbsize');
86 86
             $retVal = $this->diObj->getCommandRunner()->getReturnCode();
87 87
             $redisKeyCount = $this->diObj->getCommandRunner()->getOutput();
88 88
 
89 89
             if ($retVal!==0) {
90 90
                 if ($this->diObj->getLogger()) {
91 91
                     $this->diObj->getLogger()->error(
92
-                        'Redis KEyCount cmd failed!, RETVAL: ' . $retVal
93
-                        . ', OUT: ' . implode('|', $redisKeyCount)
92
+                        'Redis KEyCount cmd failed!, RETVAL: '.$retVal
93
+                        . ', OUT: '.implode('|', $redisKeyCount)
94 94
                     );
95 95
                 }
96 96
                 return false;
97 97
             }
98 98
             if ($redisKeyCount[0]>0) {
99
-                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd() . ' --raw keys *');
99
+                $this->diObj->getCommandRunner()->execute($this->getRedisCliCmd().' --raw keys *');
100 100
                 $retVal = $this->diObj->getCommandRunner()->getReturnCode();
101 101
                 $redisKeyList = $this->diObj->getCommandRunner()->getOutput();
102 102
                 if ($retVal!==0) {
103 103
                     if ($this->diObj->getLogger()) {
104 104
                         $this->diObj->getLogger()->error(
105
-                            'Redis KeyList cmd failed!, RETVAL: ' . $retVal
106
-                            . ', OUT: ' . implode('|', $redisKeyList)
105
+                            'Redis KeyList cmd failed!, RETVAL: '.$retVal
106
+                            . ', OUT: '.implode('|', $redisKeyList)
107 107
                         );
108 108
                     }
109 109
                     return false;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             }
115 115
         } catch (\Exception $e) {
116 116
             if ($this->diObj->getLogger()) {
117
-                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: ' . $e->getMessage());
117
+                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: '.$e->getMessage());
118 118
             }
119 119
             return false;
120 120
         }
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
     public function getMetrics()
127 127
     {
128 128
         try {
129
-            $redisKeyList = count($this->keys)==0?$this->findKeys():$this->keys;
129
+            $redisKeyList = count($this->keys)==0 ? $this->findKeys() : $this->keys;
130 130
             $totalLen     = 0;
131 131
             if ($redisKeyList && is_array($redisKeyList)) {
132 132
                 foreach ($redisKeyList as $redisKey) {
133 133
                     $this->diObj->getCommandRunner()->execute(
134
-                        $this->getRedisCliCmd() . ' --raw llen ' . trim($redisKey)
134
+                        $this->getRedisCliCmd().' --raw llen '.trim($redisKey)
135 135
                     );
136 136
                     $retVal = $this->diObj->getCommandRunner()->getReturnCode();
137 137
                     $redisKeyLen = $this->diObj->getCommandRunner()->getOutput();
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
             ];
146 146
         } catch (\Exception $e) {
147 147
             if ($this->diObj->getLogger()) {
148
-                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: ' . $e->getMessage());
148
+                $this->diObj->getLogger()->error('Redis client thrown exception! ExcpMsg: '.$e->getMessage());
149 149
             }
150 150
             return false;
151 151
         }
Please login to merge, or discard this patch.
src/AWSCustomMetric/Plugin/FileWatch.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function addPattern($pattern, $isRegExp = false)
62 62
     {
63
-        $this->patterns[ $pattern ] = $isRegExp;
63
+        $this->patterns[$pattern] = $isRegExp;
64 64
     }
65 65
 
66 66
     /**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function removePattern($pattern)
70 70
     {
71
-        unset($this->patterns[ $pattern ]);
71
+        unset($this->patterns[$pattern]);
72 72
     }
73 73
 
74 74
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         if ($matchedCount>0 && $this->diObj->getLogger()) {
93 93
             $this->diObj->getLogger()->error(
94 94
                 'FileWatch found matched line!'
95
-                .' LINE >>> ' . $line . ' <<<'
95
+                .' LINE >>> '.$line.' <<<'
96 96
             );
97 97
         }
98 98
         return $matchedCount;
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
     {
106 106
         try {
107 107
             if (is_file($this->fileToWatch)===false) {
108
-                throw new \Exception("File to watch \"". $this->fileToWatch ."\" not found!");
108
+                throw new \Exception("File to watch \"".$this->fileToWatch."\" not found!");
109 109
             }
110 110
 
111 111
             clearstatcache(true);
112
-            $checkPointFile = $this->checkPointFile?:$this->fileToWatch . '.checkpoint';
113
-            $checkPoint     = is_file($checkPointFile)?intval(file_get_contents($checkPointFile)):0;
112
+            $checkPointFile = $this->checkPointFile ?: $this->fileToWatch.'.checkpoint';
113
+            $checkPoint     = is_file($checkPointFile) ?intval(file_get_contents($checkPointFile)) : 0;
114 114
             $fileSize       = filesize($this->fileToWatch);
115 115
             if ($fileSize==0) {
116 116
                 return [
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
             }
123 123
             $fp = fopen($this->fileToWatch, 'r');
124 124
             if (!$fp) {
125
-                throw new \Exception("File to watch \"". $this->fileToWatch ."\" could not opened for read!");
125
+                throw new \Exception("File to watch \"".$this->fileToWatch."\" could not opened for read!");
126 126
             }
127 127
             $seekStatus = fseek($fp, $checkPoint);
128 128
             if ($seekStatus==-1) {
129
-                throw new \Exception("Seek to \"". $checkPoint ."\" failed for \"". $this->fileToWatch ."\"!");
129
+                throw new \Exception("Seek to \"".$checkPoint."\" failed for \"".$this->fileToWatch."\"!");
130 130
             }
131 131
 
132 132
             $newCheckPoint      = $checkPoint;
133 133
             $foundPatternsCount = 0;
134
-            while (($line = fgets($fp)) !== false) {
135
-                if (($newCheckPoint+strlen($line))>$fileSize) {
134
+            while (($line = fgets($fp))!==false) {
135
+                if (($newCheckPoint + strlen($line))>$fileSize) {
136 136
                     break;
137 137
                 }
138 138
                 $foundPatternsCount += $this->checkLine($line);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
             ];
147 147
         } catch (\Exception $e) {
148 148
             if ($this->diObj->getLogger()) {
149
-                $this->diObj->getLogger()->error('FileWatch thrown exception! ExcpMsg: ' . $e->getMessage());
149
+                $this->diObj->getLogger()->error('FileWatch thrown exception! ExcpMsg: '.$e->getMessage());
150 150
             }
151 151
             return [
152 152
                 $this->createNewMetric('FileWatchException', 'Count', 1)
Please login to merge, or discard this patch.