Completed
Push — master ( d973a4...95c720 )
by Philippe
02:01
created
EventListener/ConsoleTerminateListener.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@
 block discarded – undo
11 11
  */
12 12
 class ConsoleTerminateListener
13 13
 {
14
-    /**
15
-     * @var ChuckAPIService
16
-     */
17
-    private $chuckApiService;
14
+	/**
15
+	 * @var ChuckAPIService
16
+	 */
17
+	private $chuckApiService;
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    private $enabledEnvironments;
19
+	/**
20
+	 * @var array
21
+	 */
22
+	private $enabledEnvironments;
23 23
 
24
-    /**
25
-     * @var string
26
-     */
27
-    private $env;
24
+	/**
25
+	 * @var string
26
+	 */
27
+	private $env;
28 28
 
29
-    /**
30
-     * ConsoleTerminateListener constructor.
31
-     *
32
-     * @param ChuckAPIService $chuckAPIService
33
-     */
34
-    public function __construct(ChuckAPIService $chuckAPIService, $environments = [], $env)
35
-    {
36
-        $this->chuckApiService = $chuckAPIService;
37
-        $this->enabledEnvironments = $environments;
38
-        $this->env = $env;
39
-    }
29
+	/**
30
+	 * ConsoleTerminateListener constructor.
31
+	 *
32
+	 * @param ChuckAPIService $chuckAPIService
33
+	 */
34
+	public function __construct(ChuckAPIService $chuckAPIService, $environments = [], $env)
35
+	{
36
+		$this->chuckApiService = $chuckAPIService;
37
+		$this->enabledEnvironments = $environments;
38
+		$this->env = $env;
39
+	}
40 40
 
41
-    /**
42
-     * @param ConsoleTerminateEvent $event
43
-     */
44
-    public function onConsoleTerminate(ConsoleTerminateEvent $event)
45
-    {
46
-        if (
47
-            !$event->getCommand() instanceof ChuckCommand
48
-            && in_array($this->env, $this->enabledEnvironments)
49
-            && $fact = $this->chuckApiService->getFact()
50
-        ) {
51
-            $event->getOutput()->writeln($fact);
52
-        }
53
-    }
41
+	/**
42
+	 * @param ConsoleTerminateEvent $event
43
+	 */
44
+	public function onConsoleTerminate(ConsoleTerminateEvent $event)
45
+	{
46
+		if (
47
+			!$event->getCommand() instanceof ChuckCommand
48
+			&& in_array($this->env, $this->enabledEnvironments)
49
+			&& $fact = $this->chuckApiService->getFact()
50
+		) {
51
+			$event->getOutput()->writeln($fact);
52
+		}
53
+	}
54 54
 }
Please login to merge, or discard this patch.
ChuckFactService/ChuckAPIService.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -7,121 +7,121 @@
 block discarded – undo
7 7
 
8 8
 class ChuckAPIService
9 9
 {
10
-    /**
11
-     * If user has not its own parameters set, value will be 'Chuck'.
12
-     *
13
-     * @var string
14
-     */
15
-    private $firstName;
16
-
17
-    /**
18
-     * If user has not its own parameters set, value will be 'Norris'.
19
-     *
20
-     * @var string
21
-     */
22
-    private $lastName;
23
-
24
-    /**
25
-     * After n seconds, cancel.
26
-     *
27
-     * @var int
28
-     */
29
-    private $timeout;
30
-
31
-    /**
32
-     * @param string $firstName
33
-     * @param string $lastName
34
-     * @param int    $timeout
35
-     */
36
-    public function __construct($firstName = 'Chuck', $lastName = 'Norris', $timeout = 2)
37
-    {
38
-        $this
39
-            ->setFirstName($firstName)
40
-            ->setLastName($lastName)
41
-            ->setTimeout($timeout)
42
-        ;
43
-    }
44
-
45
-    /**
46
-     * @param string $firstName
47
-     *
48
-     * @return $this
49
-     */
50
-    public function setFirstName($firstName)
51
-    {
52
-        $this->firstName = $firstName;
53
-
54
-        return $this;
55
-    }
56
-
57
-    /**
58
-     * @param string $lastName
59
-     *
60
-     * @return $this
61
-     */
62
-    public function setLastName($lastName)
63
-    {
64
-        $this->lastName = $lastName;
65
-
66
-        return $this;
67
-    }
68
-
69
-    /**
70
-     * @param int $timeout
71
-     *
72
-     * @return $this
73
-     */
74
-    public function setTimeout($timeout)
75
-    {
76
-        $this->timeout = $timeout;
77
-
78
-        return $this;
79
-    }
80
-
81
-    /**
82
-     * Get fact from Internet Chuck Norris Database.
83
-     *
84
-     * @return string|false
85
-     */
86
-    public function getFact()
87
-    {
88
-        try {
89
-            $response = $this->getResponse();
90
-            if ($response->getStatusCode() == 200) {
91
-                $datas = json_decode($response->getBody());
92
-
93
-                return html_entity_decode(stripslashes($datas->value->joke));
94
-            }
95
-        } catch (ConnectException $e) {
96
-            return false;
97
-        }
98
-    }
99
-
100
-    /**
101
-     * @return \Psr\Http\Message\ResponseInterface
102
-     */
103
-    private function getResponse()
104
-    {
105
-        $client = $this->getClient();
106
-
107
-        $response = $client->get('random', [
108
-            'query' => [
109
-                'firstName' => $this->firstName,
110
-                'lastName' => $this->lastName,
111
-            ],
112
-        ]);
113
-
114
-        return $response;
115
-    }
116
-
117
-    /**
118
-     * @return Client
119
-     */
120
-    private function getClient()
121
-    {
122
-        return new Client([
123
-            'base_uri' => 'http://api.icndb.com/jokes/',
124
-            'timeout' => $this->timeout,
125
-        ]);
126
-    }
10
+	/**
11
+	 * If user has not its own parameters set, value will be 'Chuck'.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	private $firstName;
16
+
17
+	/**
18
+	 * If user has not its own parameters set, value will be 'Norris'.
19
+	 *
20
+	 * @var string
21
+	 */
22
+	private $lastName;
23
+
24
+	/**
25
+	 * After n seconds, cancel.
26
+	 *
27
+	 * @var int
28
+	 */
29
+	private $timeout;
30
+
31
+	/**
32
+	 * @param string $firstName
33
+	 * @param string $lastName
34
+	 * @param int    $timeout
35
+	 */
36
+	public function __construct($firstName = 'Chuck', $lastName = 'Norris', $timeout = 2)
37
+	{
38
+		$this
39
+			->setFirstName($firstName)
40
+			->setLastName($lastName)
41
+			->setTimeout($timeout)
42
+		;
43
+	}
44
+
45
+	/**
46
+	 * @param string $firstName
47
+	 *
48
+	 * @return $this
49
+	 */
50
+	public function setFirstName($firstName)
51
+	{
52
+		$this->firstName = $firstName;
53
+
54
+		return $this;
55
+	}
56
+
57
+	/**
58
+	 * @param string $lastName
59
+	 *
60
+	 * @return $this
61
+	 */
62
+	public function setLastName($lastName)
63
+	{
64
+		$this->lastName = $lastName;
65
+
66
+		return $this;
67
+	}
68
+
69
+	/**
70
+	 * @param int $timeout
71
+	 *
72
+	 * @return $this
73
+	 */
74
+	public function setTimeout($timeout)
75
+	{
76
+		$this->timeout = $timeout;
77
+
78
+		return $this;
79
+	}
80
+
81
+	/**
82
+	 * Get fact from Internet Chuck Norris Database.
83
+	 *
84
+	 * @return string|false
85
+	 */
86
+	public function getFact()
87
+	{
88
+		try {
89
+			$response = $this->getResponse();
90
+			if ($response->getStatusCode() == 200) {
91
+				$datas = json_decode($response->getBody());
92
+
93
+				return html_entity_decode(stripslashes($datas->value->joke));
94
+			}
95
+		} catch (ConnectException $e) {
96
+			return false;
97
+		}
98
+	}
99
+
100
+	/**
101
+	 * @return \Psr\Http\Message\ResponseInterface
102
+	 */
103
+	private function getResponse()
104
+	{
105
+		$client = $this->getClient();
106
+
107
+		$response = $client->get('random', [
108
+			'query' => [
109
+				'firstName' => $this->firstName,
110
+				'lastName' => $this->lastName,
111
+			],
112
+		]);
113
+
114
+		return $response;
115
+	}
116
+
117
+	/**
118
+	 * @return Client
119
+	 */
120
+	private function getClient()
121
+	{
122
+		return new Client([
123
+			'base_uri' => 'http://api.icndb.com/jokes/',
124
+			'timeout' => $this->timeout,
125
+		]);
126
+	}
127 127
 }
Please login to merge, or discard this patch.