ResponseHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A arrayResponse() 0 3 1
A fail() 0 6 2
A filename() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jonasdamher\Simplifyimage\Core;
6
7
class ResponseHandler
8
{
9
	private static array $response = [
10
		'valid' => true,
11
		'filename' => null,
12
		'errors' => []
13
	];
14
15
	/** 
16
	 * Set errors and save in array called $response.
17
	 * @param string $message - Error description.
18
	 */
19
	public static function fail(string $message)
20
	{
21
		if (self::$response['valid']) {
22
			self::$response['valid'] = false;
23
		}
24
		array_push(self::$response['errors'], $message);
25
	}
26
27
	protected static function filename(string $name)
28
	{
29
		self::$response['filename'] = $name;
30
	}
31
32
	protected static function arrayResponse(): array
33
	{
34
		return self::$response;
35
	}
36
}
37