src/Infrastructure/DataAccess/Connector/StatusReport.php
public static function generate(ConnectorMap $connector_map)
    {
        $details = [];
        $failing = 0;
        $working = 0;
        $unknown = 0;

        $connections = [];
        foreach ($connector_map as $name => $connector) {
            try {
                $connections[$name] = $connector->getStatus();
            } catch (Exception $e) {
                $connections[$name] = Status::failing(
                    $connector,
                    [ 'message' => 'Exception on getStatus(): ' . $e->getMessage() ]
                );
                error_log('Error while getting status of connection "' . $name . '": ' . $e->getTraceAsString());
            }
        }

        ksort($connections);

        foreach ($connections as $name => $connection) {
            $details[$name] = $connection->toArray();

            if ($connection->isFailing()) {
                $failing++;
            } elseif ($connection->isWorking()) {
                $working++;
            } else {
                $unknown++;
            }
        }

        $overall = $connector_map->count();

        $status = Status::UNKNOWN;
        if ($failing > 0) {
            $status = Status::FAILING;
        } elseif ($working === $overall) {
            $status = Status::WORKING;
        }

        $stats = [
            'overall' => $overall,
            'failing' => $failing,
            'working' => $working,
            'unknown' => $unknown
        ];

        return new static($status, $stats, $details);
    }
public static function generate(ConnectorMap $connector_map)
    {
        $details = [];
        $failing = 0;
        $working = 0;
        $unknown = 0;

        $connections = [];
        foreach ($connector_map as $name => $connector) {
            try {
                $connections[$name] = $connector->getStatus();
            } catch (Exception $e) {
                $connections[$name] = Status::failing(
                    $connector,
                    [ 'message' => 'Exception on getStatus(): ' . $e->getMessage() ]
                );
                error_log('Error while getting status of connection "' . $name . '": ' . $e->getTraceAsString());
            }
        }

        ksort($connections);

        foreach ($connections as $name => $connection) {
            $details[$name] = $connection->toArray();

            if ($connection->isFailing()) {
                $failing++;
            } elseif ($connection->isWorking()) {
                $working++;
            } else {
                $unknown++;
            }
        }

        $overall = $connector_map->count();

        $status = Status::UNKNOWN;
        if ($failing > 0) {
            $status = Status::FAILING;
        } elseif ($working === $overall) {
            $status = Status::WORKING;
        }

        $stats = [
            'overall' => $overall,
            'failing' => $failing,
            'working' => $working,
            'unknown' => $unknown
        ];

        return new static($status, $stats, $details);
    }
public static function generate ( ConnectorMap $ connector_map ) { $ details = [ ] ; $ failing = 0 ; $ working = 0 ; $ unknown = 0 ; $ connections = [ ] ; foreach ( $ connector_map as $ name => $ connector ) { try { $ connections [ $ name ] = $ connector -> getStatus ( ) ; } catch ( Exception $ e ) { $ connections [ $ name ] = Status :: failing ( $ connector , [ 'message' => 'Exception on getStatus(): ' . $ e -> getMessage ( ) ] ) ; error_log ( 'Error while getting status of connection "' . $ name . '": ' . $ e -> getTraceAsString ( ) ) ; } } ksort ( $ connections ) ; foreach ( $ connections as $ name => $ connection ) { $ details [ $ name ] = $ connection -> toArray ( ) ; if ( $ connection -> isFailing ( ) ) { $ failing ++ ; } elseif ( $ connection -> isWorking ( ) ) { $ working ++ ; } else { $ unknown ++ ; } } $ overall = $ connector_map -> count ( ) ; $ status = Status :: UNKNOWN ; if ( $ failing > 0 ) { $ status = Status :: FAILING ; } elseif ( $ working === $ overall ) { $ status = Status :: WORKING ; } $ stats = [ 'overall' => $ overall , 'failing' => $ failing , 'working' => $ working , 'unknown' => $ unknown ] ; return new static ( $ status , $ stats , $ details ) ; }
Generates a new StatusReport by getting the Status from all known connections.

@todo Should only specific exceptions be catched when getStatus() is called on the connectors? Rethrow?

@param ConnectorMap $connector_map

@return StatusReport
Generates a new StatusReport by getting the Status from all known connections .