# billingo/4.2.9/src/Service/SelfTest.php

Billingo Official for WooCommerce, version 4.2.9. 61 lines.

- Page: https://pluginprobe.com/plugins/billingo/4.2.9/code/src/Service/SelfTest.php
- Raw: https://pluginprobe.com/plugins/billingo/4.2.9/raw/src/Service/SelfTest.php
- Modified: 2025-05-26T04:53:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/billingo/4.2.9/code/src/Service/SelfTest.php#L10-L20`.

```php
<?php

namespace App\Billingo\Service;

use App\Billingo\Error\BillingoError;

class SelfTest
{

    private ?array $errors = null;

    public function __construct(private readonly string $name, private readonly array $controlTree)
    {
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function getControlTree(): array
    {
        return $this->controlTree;
    }

    public function getErrors(): ?array
    {
        if ($this->errors) {

            return $this->errors;
        }

        $this->errors = $this->findErrors($this->controlTree);

        return $this->errors;
    }

    private function findErrors(array $data): ?array
    {
        $errors = [];

        foreach ($data as $class => $status) {

            if (is_array($status)) {
                $localError = $this->findErrors($status);

                if (!empty($localError)) {

                    $errors[$class] = $localError;
                }
            } else {
                if ($status instanceof BillingoError) {
                    $errors[$class] = $status;
                }
            }
        }

        return empty($errors) ? null : $errors;
    }
}

```
