]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Command/WeatherCommand.php
Version 0.6.0
[airbundle] / Command / WeatherCommand.php
index a7572b02e7dfdd8981fd76296215c7f38e793c9b..4bce6683ef2263eb6eef30b1e02051265806c37d 100644 (file)
@@ -75,27 +75,15 @@ class WeatherCommand extends DoctrineCommand {
        ];
 
        ///Set curl handler
-       private $ch = null;
-
-       ///Set manager registry
-       private $doctrine;
-
-       ///Set filesystem
-       private $filesystem;
+       private \CurlHandle|false $ch = false;
 
        ///Weather command constructor
-       public function __construct(ManagerRegistry $doctrine, Filesystem $filesystem) {
+       public function __construct(private ManagerRegistry $doctrine, private Filesystem $filesystem) {
                parent::__construct($doctrine);
-
-               //Set entity manager
-               $this->doctrine = $doctrine;
-
-               //Set filesystem
-               $this->filesystem = $filesystem;
        }
 
        ///Configure attribute command
-       protected function configure() {
+       protected function configure():void {
                //Configure the class
                $this
                        //Set name
@@ -504,9 +492,6 @@ class WeatherCommand extends DoctrineCommand {
                //Flush to get the ids
                $this->doctrine->getManager()->flush();
 
-               //Close curl handler
-               $this->curl_close();
-
                //Return success
                return self::SUCCESS;
        }
@@ -653,9 +638,6 @@ class WeatherCommand extends DoctrineCommand {
                        //Display error
                        echo 'Setopt for '.$url.' failed: '.curl_error($this->ch)."\n";
 
-                       //Close curl handler
-                       curl_close($this->ch);
-
                        //Exit with failure
                        exit(self::FAILURE);
                }
@@ -671,9 +653,6 @@ class WeatherCommand extends DoctrineCommand {
                        //Display response
                        var_dump($response);
 
-                       //Close curl handler
-                       curl_close($this->ch);
-
                        //Exit with failure
                        exit(self::FAILURE);
                }
@@ -689,9 +668,6 @@ class WeatherCommand extends DoctrineCommand {
                        //Display response
                        var_dump($response);
 
-                       //Close curl handler
-                       curl_close($this->ch);
-
                        //Exit with failure
                        exit(self::FAILURE);
                }
@@ -707,9 +683,6 @@ class WeatherCommand extends DoctrineCommand {
                        //Display response
                        var_dump($response);
 
-                       //Close curl handler
-                       curl_close($this->ch);
-
                        //Exit with failure
                        exit(self::FAILURE);
                }
@@ -725,9 +698,6 @@ class WeatherCommand extends DoctrineCommand {
                        //Display response
                        var_dump($header);
 
-                       //Close curl handler
-                       curl_close($this->ch);
-
                        //Exit with failure
                        exit(self::FAILURE);
                }
@@ -735,13 +705,4 @@ class WeatherCommand extends DoctrineCommand {
                //Return content
                return substr($response, $hs);
        }
-
-       /**
-        * Close curl handler
-        *
-        * @return bool Return success or failure
-        */
-       function curl_close() {
-               return curl_close($this->ch);
-       }
 }