You are here

private function DebuggingReviewForm::extractModule in Lightweight Directory Access Protocol (LDAP) 8.4

Extract module information.

Parameters

string $row: Row.

string $nextRow: Next row.

array $modules: Extracted modules data.

1 call to DebuggingReviewForm::extractModule()
DebuggingReviewForm::parsePhpModules in ldap_servers/src/Form/DebuggingReviewForm.php
Generates an array of values from phpinfo().

File

ldap_servers/src/Form/DebuggingReviewForm.php, line 230

Class

DebuggingReviewForm
Form to allow for debugging review.

Namespace

Drupal\ldap_servers\Form

Code

private function extractModule(string $row, string $nextRow, array &$modules) : void {
  if (preg_match('/<h2>([^<]+)<\\/h2>/', $row, $headingMatches)) {
    $moduleName = trim($headingMatches[1]);
    $moduleInfos = explode("\n", $nextRow);
    foreach ($moduleInfos as $info) {
      $infoPattern = '<info>([^<]+)<\\/info>';

      // 3 columns.
      if (preg_match("/{$infoPattern}\\s*{$infoPattern}\\s*{$infoPattern}/", $info, $infoMatches)) {
        $modules[$moduleName][trim($infoMatches[1])] = [
          trim($infoMatches[2]),
          trim($infoMatches[3]),
        ];
      }
      elseif (preg_match("/{$infoPattern}\\s*{$infoPattern}/", $info, $infoMatches)) {
        $modules[$moduleName][trim($infoMatches[1])] = trim($infoMatches[2]);
      }
    }
  }
}