Completed
Pull Request — master (#359)
by Maxence
41s
created
lib/Vendor/Elastic/Transport/Serializer/CsvSerializer.php 3 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,39 +24,39 @@
 block discarded – undo
24 24
 
25 25
 class CsvSerializer implements SerializerInterface
26 26
 {
27
-    /**
28
-     * @inheritdoc
29
-     * 
30
-     * @throws InvalidIterableException
31
-     */
32
-    public static function serialize($data, array $options = []): string
33
-    {
34
-        if (!is_iterable($data)) {
35
-            throw new InvalidIterableException(
36
-                sprintf("The parameter %s is not iterable", serialize($data))
37
-            );
38
-        }
39
-        $result = '';
40
-        foreach ($data as $row) {
41
-            if (is_array($row) || is_object($row)) {
42
-                $result .= implode(',', (array) $row);
43
-            } else {
44
-                $result .= (string) $row;
45
-            }
46
-            $result .= "\n";
47
-        }
48
-        return empty($result) ? $result : substr($result, 0, -1);
49
-    }
27
+	/**
28
+	 * @inheritdoc
29
+	 * 
30
+	 * @throws InvalidIterableException
31
+	 */
32
+	public static function serialize($data, array $options = []): string
33
+	{
34
+		if (!is_iterable($data)) {
35
+			throw new InvalidIterableException(
36
+				sprintf("The parameter %s is not iterable", serialize($data))
37
+			);
38
+		}
39
+		$result = '';
40
+		foreach ($data as $row) {
41
+			if (is_array($row) || is_object($row)) {
42
+				$result .= implode(',', (array) $row);
43
+			} else {
44
+				$result .= (string) $row;
45
+			}
46
+			$result .= "\n";
47
+		}
48
+		return empty($result) ? $result : substr($result, 0, -1);
49
+	}
50 50
 
51
-    /**
52
-     * @return array
53
-     */
54
-    public static function unserialize(string $data, array $options = []): array
55
-    {
56
-        $result = [];
57
-        foreach (explode("\n", $data) as $row) {
58
-            $result[] = str_getcsv($row);
59
-        }
60
-        return $result;
61
-    }
51
+	/**
52
+	 * @return array
53
+	 */
54
+	public static function unserialize(string $data, array $options = []): array
55
+	{
56
+		$result = [];
57
+		foreach (explode("\n", $data) as $row) {
58
+			$result[] = str_getcsv($row);
59
+		}
60
+		return $result;
61
+	}
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@
 block discarded – undo
39 39
         $result = '';
40 40
         foreach ($data as $row) {
41 41
             if (is_array($row) || is_object($row)) {
42
-                $result .= implode(',', (array) $row);
42
+                $result .= implode(',', (array)$row);
43 43
             } else {
44
-                $result .= (string) $row;
44
+                $result .= (string)$row;
45 45
             }
46 46
             $result .= "\n";
47 47
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@
 block discarded – undo
22 22
 use function str_getcsv;
23 23
 use function substr;
24 24
 
25
-class CsvSerializer implements SerializerInterface
26
-{
25
+class CsvSerializer implements SerializerInterface {
27 26
     /**
28 27
      * @inheritdoc
29 28
      * 
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Serializer/Utility.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,32 +23,32 @@
 block discarded – undo
23 23
 
24 24
 class Utility
25 25
 {
26
-    /**
27
-     * Remove null values form array or object
28
-     * 
29
-     * @param mixed $data
30
-     * @return void
31
-     */
32
-    public static function removeNullValue(&$data): void
33
-    {
34
-        if (!is_object($data) && !is_array($data)) {
35
-            throw new InvalidArgumentException(
36
-                sprintf("The parameter %s must be an object or array", var_export($data, true))
37
-            );
38
-        }
39
-        /** @phpstan-ignore-next-line */
40
-        foreach ($data as $property => &$value) {
41
-            if (is_object($value) || is_array($value)) {
42
-                self::removeNullValue($value);
43
-            }
44
-            if (null === $value) {
45
-                if (is_array($data)) {
46
-                    unset($data[$property]);
47
-                } 
48
-                if (is_object($data)) {
49
-                    unset($data->$property);
50
-                }
51
-            }
52
-        }
53
-    }
26
+	/**
27
+	 * Remove null values form array or object
28
+	 * 
29
+	 * @param mixed $data
30
+	 * @return void
31
+	 */
32
+	public static function removeNullValue(&$data): void
33
+	{
34
+		if (!is_object($data) && !is_array($data)) {
35
+			throw new InvalidArgumentException(
36
+				sprintf("The parameter %s must be an object or array", var_export($data, true))
37
+			);
38
+		}
39
+		/** @phpstan-ignore-next-line */
40
+		foreach ($data as $property => &$value) {
41
+			if (is_object($value) || is_array($value)) {
42
+				self::removeNullValue($value);
43
+			}
44
+			if (null === $value) {
45
+				if (is_array($data)) {
46
+					unset($data[$property]);
47
+				} 
48
+				if (is_object($data)) {
49
+					unset($data->$property);
50
+				}
51
+			}
52
+		}
53
+	}
54 54
 }
55 55
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@
 block discarded – undo
21 21
 use function var_export;
22 22
 use function sprintf;
23 23
 
24
-class Utility
25
-{
24
+class Utility {
26 25
     /**
27 26
      * Remove null values form array or object
28 27
      * 
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Serializer/NDJsonSerializer.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -25,51 +25,51 @@
 block discarded – undo
25 25
 
26 26
 class NDJsonSerializer implements SerializerInterface
27 27
 {
28
-    /**
29
-     * The available $options are: 
30
-     * 'remove_null'  => (bool) enable/disable the removing of
31
-     *                   null values (default is true)
32
-     * 
33
-     * @param array $data
34
-     */
35
-    public static function serialize($data, array $options = []): string
36
-    {
37
-        $result = '';
38
-        foreach ($data as $row) {
39
-            if (empty($row)) {
40
-                $result .= "{}\n";
41
-                continue;
42
-            }
43
-            $result .= JsonSerializer::serialize($row, $options) . "\n";
44
-        }
45
-        return $result;
46
-    }
28
+	/**
29
+	 * The available $options are: 
30
+	 * 'remove_null'  => (bool) enable/disable the removing of
31
+	 *                   null values (default is true)
32
+	 * 
33
+	 * @param array $data
34
+	 */
35
+	public static function serialize($data, array $options = []): string
36
+	{
37
+		$result = '';
38
+		foreach ($data as $row) {
39
+			if (empty($row)) {
40
+				$result .= "{}\n";
41
+				continue;
42
+			}
43
+			$result .= JsonSerializer::serialize($row, $options) . "\n";
44
+		}
45
+		return $result;
46
+	}
47 47
 
48
-    /**
49
-     * The available options are:
50
-     * 'type' => (string) specify if the array result should contain object
51
-     *           or array (default is array)
52
-     * 
53
-     * @inheritdoc
54
-     */
55
-    public static function unserialize(string $data, array $options = [])
56
-    {
57
-        $array = explode(strpos($data, "\r\n") !== false ? "\r\n" : "\n", $data);
58
-        $result = [];
59
-        foreach ($array as $json) {
60
-            if (empty($json)) {
61
-                continue;
62
-            }
63
-            try {
64
-                $result[] = JsonSerializer::unserialize($json, $options);
65
-            } catch (JsonException $e) {
66
-                throw new InvalidJsonException(sprintf(
67
-                    "Not a valid NDJson: %s", 
68
-                    $e->getMessage()
69
-                ));
70
-            }    
71
-        }
72
-        $type = $options['type'] ?? 'array';
73
-        return $type === 'array' ? $result : new ArrayObject($result);
74
-    }
48
+	/**
49
+	 * The available options are:
50
+	 * 'type' => (string) specify if the array result should contain object
51
+	 *           or array (default is array)
52
+	 * 
53
+	 * @inheritdoc
54
+	 */
55
+	public static function unserialize(string $data, array $options = [])
56
+	{
57
+		$array = explode(strpos($data, "\r\n") !== false ? "\r\n" : "\n", $data);
58
+		$result = [];
59
+		foreach ($array as $json) {
60
+			if (empty($json)) {
61
+				continue;
62
+			}
63
+			try {
64
+				$result[] = JsonSerializer::unserialize($json, $options);
65
+			} catch (JsonException $e) {
66
+				throw new InvalidJsonException(sprintf(
67
+					"Not a valid NDJson: %s", 
68
+					$e->getMessage()
69
+				));
70
+			}    
71
+		}
72
+		$type = $options['type'] ?? 'array';
73
+		return $type === 'array' ? $result : new ArrayObject($result);
74
+	}
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
                 $result .= "{}\n";
41 41
                 continue;
42 42
             }
43
-            $result .= JsonSerializer::serialize($row, $options) . "\n";
43
+            $result .= JsonSerializer::serialize($row, $options)."\n";
44 44
         }
45 45
         return $result;
46 46
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
 use function sprintf;
24 24
 use function strpos;
25 25
 
26
-class NDJsonSerializer implements SerializerInterface
27
-{
26
+class NDJsonSerializer implements SerializerInterface {
28 27
     /**
29 28
      * The available $options are: 
30 29
      * 'remove_null'  => (bool) enable/disable the removing of
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Async/OnSuccessInterface.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
 
19 19
 interface OnSuccessInterface
20 20
 {
21
-    /**
22
-     * @return mixed
23
-     */
24
-    public function success(ResponseInterface $request, int $count);
21
+	/**
22
+	 * @return mixed
23
+	 */
24
+	public function success(ResponseInterface $request, int $count);
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface;
18 18
 
19
-interface OnSuccessInterface
20
-{
19
+interface OnSuccessInterface {
21 20
     /**
22 21
      * @return mixed
23 22
      */
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Async/OnSuccessDefault.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
 
19 19
 class OnSuccessDefault implements OnSuccessInterface
20 20
 {
21
-    public function success(ResponseInterface $response, int $count)
22
-    {
23
-        return $response;
24
-    }
21
+	public function success(ResponseInterface $response, int $count)
22
+	{
23
+		return $response;
24
+	}
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface;
18 18
 
19
-class OnSuccessDefault implements OnSuccessInterface
20
-{
19
+class OnSuccessDefault implements OnSuccessInterface {
21 20
     public function success(ResponseInterface $response, int $count)
22 21
     {
23 22
         return $response;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Async/OnFailureDefault.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 
21 21
 class OnFailureDefault implements OnFailureInterface
22 22
 {
23
-    public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void
24
-    {
25
-    }
23
+	public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void
24
+	{
25
+	}
26 26
 }
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@
 block discarded – undo
18 18
 use Exception;
19 19
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface;
20 20
 
21
-class OnFailureDefault implements OnFailureInterface
22
-{
21
+class OnFailureDefault implements OnFailureInterface {
23 22
     public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void
24 23
     {
25 24
     }
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Async/OnFailureInterface.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,5 +20,5 @@
 block discarded – undo
20 20
 
21 21
 interface OnFailureInterface
22 22
 {
23
-    public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void;
23
+	public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void;
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
18 18
 use Exception;
19 19
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface;
20 20
 
21
-interface OnFailureInterface
22
-{
21
+interface OnFailureInterface {
23 22
     public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null): void;
24 23
 }
25 24
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Exception/RuntimeException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 
17 17
 use RuntimeException as RootRuntimeException;
18 18
 
19
-class RuntimeException extends RootRuntimeException implements TransportException
20
-{
19
+class RuntimeException extends RootRuntimeException implements TransportException {
21 20
 
22 21
 }
23 22
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Exception/NoNodeAvailableException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 
17 17
 use RuntimeException;
18 18
 
19
-class NoNodeAvailableException extends RuntimeException implements TransportException
20
-{
19
+class NoNodeAvailableException extends RuntimeException implements TransportException {
21 20
 
22 21
 }
23 22
\ No newline at end of file
Please login to merge, or discard this patch.