PluginProbe
Billingo Official for WooCommerce / trunk
Billingo Official for WooCommerce vtrunk
4.3.3 4.3.2 trunk 0.0.2 1.0.0 2.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 All 82 releases
billingo / src / Service / SelfTest.php

SelfTest.php in Billingo Official for WooCommerce trunk, at src/Service/SelfTest.php

61 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace App\Billingo\Service;
4
5 use App\Billingo\Error\BillingoError;
6
7 class SelfTest
8 {
9
10 private ?array $errors = null;
11
12 public function __construct(private readonly string $name, private readonly array $controlTree)
13 {
14 }
15
16 public function getName(): string
17 {
18 return $this->name;
19 }
20
21 public function getControlTree(): array
22 {
23 return $this->controlTree;
24 }
25
26 public function getErrors(): ?array
27 {
28 if ($this->errors) {
29
30 return $this->errors;
31 }
32
33 $this->errors = $this->findErrors($this->controlTree);
34
35 return $this->errors;
36 }
37
38 private function findErrors(array $data): ?array
39 {
40 $errors = [];
41
42 foreach ($data as $class => $status) {
43
44 if (is_array($status)) {
45 $localError = $this->findErrors($status);
46
47 if (!empty($localError)) {
48
49 $errors[$class] = $localError;
50 }
51 } else {
52 if ($status instanceof BillingoError) {
53 $errors[$class] = $status;
54 }
55 }
56 }
57
58 return empty($errors) ? null : $errors;
59 }
60 }
61