Completed
Push — master ( 575823...f7fea2 )
by Stefano
02:38
created
Plugins/RaspPIVolume_plugin/RaspPIVolume_plugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @website http://www.stefanobianchini.net
14 14
  * Bash script from http://www.dronkert.net/rpi/vol.html
15 15
  */
16
-class RaspPIVolume_plugin implements \JarvisPHP\Core\JarvisPluginInterface{
16
+class RaspPIVolume_plugin implements \JarvisPHP\Core\JarvisPluginInterface {
17 17
     /**
18 18
      * Priority of plugin
19 19
      * @var int  
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
     function answer($command) {
28 28
         $answer = '';
29 29
 
30
-        if(preg_match(JarvisLanguage::translate('preg_match_mute',get_called_class()), $command)) {
30
+        if (preg_match(JarvisLanguage::translate('preg_match_mute', get_called_class()), $command)) {
31 31
             //Mute command
32 32
             exec(_JARVISPHP_ROOT_PATH.'/Plugins/RaspPIVolume_plugin/vol.sh 0');
33
-        } else if(preg_match(JarvisLanguage::translate('preg_match_unmute',get_called_class()), $command)) {
33
+        } else if (preg_match(JarvisLanguage::translate('preg_match_unmute', get_called_class()), $command)) {
34 34
             //Unmute command
35 35
             exec(_JARVISPHP_ROOT_PATH.'/Plugins/RaspPIVolume_plugin/vol.sh 65');
36
-        } else if(preg_match(JarvisLanguage::translate('preg_match_volume_up',get_called_class()), $command)) {
36
+        } else if (preg_match(JarvisLanguage::translate('preg_match_volume_up', get_called_class()), $command)) {
37 37
             //Volume up command
38 38
             exec(_JARVISPHP_ROOT_PATH.'/Plugins/RaspPIVolume_plugin/vol.sh +');
39
-        } else if(preg_match(JarvisLanguage::translate('preg_match_volume_down',get_called_class()), $command)) {
39
+        } else if (preg_match(JarvisLanguage::translate('preg_match_volume_down', get_called_class()), $command)) {
40 40
             //Volume down
41 41
             exec(_JARVISPHP_ROOT_PATH.'/Plugins/RaspPIVolume_plugin/vol.sh -');
42 42
         }
43
-        $answer = JarvisLanguage::translate('command_executed',get_called_class());
43
+        $answer = JarvisLanguage::translate('command_executed', get_called_class());
44 44
         $response = new \JarvisPHP\Core\JarvisResponse($answer, JarvisPHP::getRealClassName(get_called_class()), true);
45 45
         $response->send();
46 46
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @return boolean
59 59
      */
60 60
     function isLikely($command) {
61
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
61
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
62 62
     }
63 63
     
64 64
     /**
Please login to merge, or discard this patch.
Plugins/ActualOutsideTemperature_plugin/ActualOutsideTemperature_plugin.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
         
30 30
         $BASE_URL = "http://query.yahooapis.com/v1/public/yql";
31 31
         $yql_query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'.$this->place.'") and u="c"';
32
-        $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json";
32
+        $yql_query_url = $BASE_URL."?q=".urlencode($yql_query)."&format=json";
33 33
         
34 34
         // Make call with cURL
35 35
         $session = curl_init($yql_query_url);
36
-        curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
36
+        curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
37 37
         $json = curl_exec($session);
38 38
         // Convert JSON to PHP object
39
-        $phpObj =  json_decode($json);
40
-        $answer = sprintf(JarvisLanguage::translate('actual_temperature_outside_is',get_called_class()),$phpObj->query->results->channel->item->condition->temp, $phpObj->query->results->channel->atmosphere->humidity);
39
+        $phpObj = json_decode($json);
40
+        $answer = sprintf(JarvisLanguage::translate('actual_temperature_outside_is', get_called_class()), $phpObj->query->results->channel->item->condition->temp, $phpObj->query->results->channel->atmosphere->humidity);
41 41
         JarvisTTS::speak($answer);
42 42
         $response = new \JarvisPHP\Core\JarvisResponse($answer, JarvisPHP::getRealClassName(get_called_class()), true);
43 43
         $response->send();
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @return boolean
59 59
      */
60 60
     function isLikely($command) {
61
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
61
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
62 62
     }
63 63
     
64 64
     /**
Please login to merge, or discard this patch.
Plugins/Hello_plugin/Hello_plugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @author Stefano Bianchini
13 13
  * @website http://www.stefanobianchini.net
14 14
  */
15
-class Hello_plugin implements \JarvisPHP\Core\JarvisPluginInterface{
15
+class Hello_plugin implements \JarvisPHP\Core\JarvisPluginInterface {
16 16
     /**
17 17
      * Priority of plugin
18 18
      * @var int  
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
         $answer = '';
28 28
         JarvisPHP::getLogger()->debug('Answering to command: "'.$command.'"');
29 29
         $hour = date("H");
30
-        if($hour>5 && $hour<=13) {
30
+        if ($hour > 5 && $hour <= 13) {
31 31
             //Morning
32
-            $answer = JarvisLanguage::translate('hello_morning',get_called_class());
32
+            $answer = JarvisLanguage::translate('hello_morning', get_called_class());
33 33
         }
34
-        else if($hour>13 && $hour<18) {
34
+        else if ($hour > 13 && $hour < 18) {
35 35
             //Afternoon
36
-            $answer = JarvisLanguage::translate('hello_afternoon',get_called_class());
36
+            $answer = JarvisLanguage::translate('hello_afternoon', get_called_class());
37 37
         } else {
38 38
             //Evening (and night, of course)
39
-            $answer = JarvisLanguage::translate('hello_evening',get_called_class());
39
+            $answer = JarvisLanguage::translate('hello_evening', get_called_class());
40 40
         }
41 41
         
42 42
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @return boolean
60 60
      */
61 61
     function isLikely($command) {
62
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
62
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
63 63
     }
64 64
     
65 65
     /**
Please login to merge, or discard this patch.
Plugins/Radio_plugin/Radio_plugin.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
     function answer($command) {
27 27
         
28 28
         $start_vlc = false;
29
-        $stream_url='';
30
-        $answer='nothing done';
29
+        $stream_url = '';
30
+        $answer = 'nothing done';
31 31
         
32 32
         $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
33 33
                     
34
-        if(preg_match(JarvisLanguage::translate('preg_match_relax_music',get_called_class()), $command)) { 
34
+        if (preg_match(JarvisLanguage::translate('preg_match_relax_music', get_called_class()), $command)) { 
35 35
             $stream_url = 'http://pub4.radiotunes.com:80/radiotunes_relaxation_aacplus.flv';
36 36
             JarvisPHP::getLogger()->debug('Playing relaxation');
37 37
             $start_vlc = true;
38 38
         }
39
-        if(preg_match(JarvisLanguage::translate('preg_match_lounge_music',get_called_class()), $command)) {
39
+        if (preg_match(JarvisLanguage::translate('preg_match_lounge_music', get_called_class()), $command)) {
40 40
             $stream_url = 'http://pub4.radiotunes.com:80/radiotunes_smoothlounge_aacplus.flv';
41 41
             JarvisPHP::getLogger()->debug('Playing lounge');
42 42
             $start_vlc = true;
43 43
         }
44
-        if(preg_match(JarvisLanguage::translate('preg_match_jazz_music',get_called_class()), $command)) { 
44
+        if (preg_match(JarvisLanguage::translate('preg_match_jazz_music', get_called_class()), $command)) { 
45 45
             $stream_url = 'http://pub4.radiotunes.com:80/radiotunes_smoothjazz_aacplus.flv';
46 46
             JarvisPHP::getLogger()->debug('Playing jazz');
47 47
             $start_vlc = true;
48 48
         }
49
-        if(preg_match(JarvisLanguage::translate('preg_match_stop',get_called_class()), $command)) {
49
+        if (preg_match(JarvisLanguage::translate('preg_match_stop', get_called_class()), $command)) {
50 50
             $result = @socket_connect($socket, 'localhost', 9999);
51 51
             if ($result === false) {
52 52
                 //Error handling
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             }
64 64
             $start_vlc = false;    
65 65
         }
66
-        if($start_vlc) {
66
+        if ($start_vlc) {
67 67
             //Start Vlc on port 9999
68 68
             //exec('vlc -I rc --rc-host localhost:9999');
69 69
             @exec('/usr/bin/nohup /usr/bin/vlc -I rc --rc-host localhost:9999 &');
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      * @return boolean
105 105
      */
106 106
     function isLikely($command) {
107
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
107
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
108 108
     }
109 109
     
110 110
     /**
Please login to merge, or discard this patch.
Plugins/Gcalendar_plugin/cli_createKey.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     $accessToken = $client->authenticate($authCode);
30 30
 
31 31
     // Store the credentials to disk.
32
-    if(!file_exists(dirname($credentialsPath))) {
32
+    if (!file_exists(dirname($credentialsPath))) {
33 33
       mkdir(dirname($credentialsPath), 0700, true);
34 34
     }
35 35
     file_put_contents($credentialsPath, $accessToken);
Please login to merge, or discard this patch.
Plugins/Gcalendar_plugin/Gcalendar_plugin.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @author Stefano Bianchini
21 21
  * @website http://www.stefanobianchini.net
22 22
  */
23
-class Gcalendar_plugin implements \JarvisPHP\Core\JarvisPluginInterface{
23
+class Gcalendar_plugin implements \JarvisPHP\Core\JarvisPluginInterface {
24 24
     /**
25 25
      * Priority of plugin
26 26
      * @var int  
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         // Get the API client and construct the service object.
40 40
         $client = Gcalendar_plugin::getClient();
41 41
         
42
-        if($client==null) return null;
42
+        if ($client == null) return null;
43 43
 
44 44
         $service = new \Google_Service_Calendar($client);
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $results = $service->events->listEvents($calendarId, $optParams);
55 55
 
56 56
         if (count($results->getItems()) == 0) {
57
-          $answer = JarvisLanguage::translate('no_appointments',get_called_class());
57
+          $answer = JarvisLanguage::translate('no_appointments', get_called_class());
58 58
         } else {
59 59
           
60 60
           foreach ($results->getItems() as $event) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             }
65 65
 
66 66
             $date = new \DateTime($start);
67
-            $answer.= sprintf(JarvisLanguage::translate('list_events',get_called_class()), $date->format('j'), JarvisLanguage::translate('month_'.$date->format('n'),get_called_class()), $date->format('H'), $date->format('i'), $event->getSummary())."\n";
67
+            $answer .= sprintf(JarvisLanguage::translate('list_events', get_called_class()), $date->format('j'), JarvisLanguage::translate('month_'.$date->format('n'), get_called_class()), $date->format('H'), $date->format('i'), $event->getSummary())."\n";
68 68
           }
69 69
         }
70 70
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @return boolean
87 87
      */
88 88
     function isLikely($command) {
89
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
89
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
90 90
     }
91 91
     
92 92
     /**
Please login to merge, or discard this patch.
Plugins/Wemo_plugin/Wemo_plugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @author Stefano Bianchini
13 13
  * @website http://www.stefanobianchini.net
14 14
  */
15
-class Wemo_plugin implements \JarvisPHP\Core\JarvisPluginInterface{
15
+class Wemo_plugin implements \JarvisPHP\Core\JarvisPluginInterface {
16 16
     /**
17 17
      * Priority of plugin
18 18
      * @var int  
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $_IFTTT_MAKER_EVENT = '';
32 32
 
33 33
         //Load API key from json config
34
-        if(file_exists('Plugins/Wemo_plugin/api-key.json')) {
34
+        if (file_exists('Plugins/Wemo_plugin/api-key.json')) {
35 35
             //Create your own api key and put it in api-key.json
36 36
             $json_config = json_decode(file_get_contents('Plugins/Wemo_plugin/api-key.json'));
37 37
             $_IFTTT_MAKER_KEY = $json_config->ifttt_key;
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
61 61
         $result = curl_exec($ch);
62 62
         
63
-        if(!$result) {
63
+        if (!$result) {
64 64
             JarvisPHP::getLogger()->error('Curl error: '.curl_error($ch));
65
-            $answer = JarvisLanguage::translate('command_not_sent',get_called_class());  
65
+            $answer = JarvisLanguage::translate('command_not_sent', get_called_class());  
66 66
         }
67 67
         else {
68
-            $answer = JarvisLanguage::translate('command_sent_to_light_switch',get_called_class());    
68
+            $answer = JarvisLanguage::translate('command_sent_to_light_switch', get_called_class());    
69 69
         }
70 70
         
71 71
         curl_close($ch);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * @return boolean
90 90
      */
91 91
     function isLikely($command) {
92
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
92
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
93 93
     }
94 94
     
95 95
     /**
Please login to merge, or discard this patch.
Plugins/InformationOn_plugin/InformationOn_plugin.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @website http://www.stefanobianchini.net
14 14
  * Based on Wiki_plugin of UgoRaffaele https://github.com/UgoRaffaele/
15 15
  */
16
-class InformationOn_plugin implements \JarvisPHP\Core\JarvisPluginInterface{
16
+class InformationOn_plugin implements \JarvisPHP\Core\JarvisPluginInterface {
17 17
     /**
18 18
      * Priority of plugin
19 19
      * @var int  
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
      */
27 27
     function answer($command) {
28 28
         //Extract search term
29
-        preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command, $matches);
29
+        preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command, $matches);
30 30
         $search_term = $matches[2];
31
-		$wiki_query_url = _WIKI_URL . "?action=opensearch&search=" . urlencode($search_term) . "&format=xml&limit=5";
31
+		$wiki_query_url = _WIKI_URL."?action=opensearch&search=".urlencode($search_term)."&format=xml&limit=5";
32 32
 		$xml = simplexml_load_string(file_get_contents($wiki_query_url));
33 33
         $item_array = $xml->Section->Item;
34
-        $answer = JarvisLanguage::translate('nothing_found',get_called_class());
34
+        $answer = JarvisLanguage::translate('nothing_found', get_called_class());
35 35
         //Have i got results?
36
-        if(count($item_array)>0) {
36
+        if (count($item_array) > 0) {
37 37
             foreach ($item_array as $item) {
38 38
                 if (strlen($item->Description) > 0) {
39
-                    $answer = sprintf(JarvisLanguage::translate('search_result_is',get_called_class()), $item->Description);
39
+                    $answer = sprintf(JarvisLanguage::translate('search_result_is', get_called_class()), $item->Description);
40 40
                     break;
41 41
                 }
42 42
             }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return boolean
61 61
      */
62 62
     function isLikely($command) {
63
-        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin',get_called_class()), $command);
63
+        return preg_match(JarvisLanguage::translate('preg_match_activate_plugin', get_called_class()), $command);
64 64
     }
65 65
     
66 66
     /**
Please login to merge, or discard this patch.
Core/JarvisLanguage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         $_lang = array();
20 20
         JarvisLanguage::$data['core'] = array();
21 21
         //Loading JarvisPHP Core language
22
-        if(file_exists('language/JarvisPHP_'._LANGUAGE.'.php')) {
22
+        if (file_exists('language/JarvisPHP_'._LANGUAGE.'.php')) {
23 23
             require 'language/JarvisPHP_'._LANGUAGE.'.php';
24 24
             JarvisLanguage::$data['core'] = array_merge(JarvisLanguage::$data['core'], $_lang);
25 25
         }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $language_file = 'Plugins/'.$plugin_class.'/language/'.$plugin_class."_"._LANGUAGE.'.php';
37 37
 
38 38
         //Check if translation file exists
39
-        if(file_exists($language_file)) {
39
+        if (file_exists($language_file)) {
40 40
             require $language_file;
41 41
             JarvisLanguage::$data[$plugin] = array_merge(JarvisLanguage::$data[$plugin], $_lang);
42 42
         }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
      * @param string $plugin
49 49
      * @return string
50 50
      */
51
-    public static function translate($text, $plugin='core') {
52
-        if(isset(JarvisLanguage::$data[$plugin][$text])) {
51
+    public static function translate($text, $plugin = 'core') {
52
+        if (isset(JarvisLanguage::$data[$plugin][$text])) {
53 53
             return JarvisLanguage::$data[$plugin][$text];
54 54
         } else {
55 55
             return $text;
Please login to merge, or discard this patch.