QuailApiValidation.php in Quail API 8
File
src/QuailApiValidation.php
View source
<?php
namespace Drupal\quail_api;
use Drupal\quail_api\QuailApiSettings;
class QuailApiValidation {
public static function validate($html, $standard, $severity = NULL) {
$results = [
'report' => NULL,
'total' => 0,
];
$include_path = drupal_get_path('module', 'quail_api');
if (!file_exists($include_path . '/vendor/quail/quail.php')) {
$results['report'] = FALSE;
return $results;
}
include_once $include_path . '/vendor/quail/quail.php';
include_once $include_path . "/includes/quail_api_guidelines.inc";
include_once $include_path . "/includes/quail_api_reporters.inc";
if (empty($html)) {
$results['report'] = [];
return $results;
}
if (!is_array($severity)) {
$severity = QuailApiSettings::get_default_severity();
}
$quail = new \quail($html, $standard['guideline'], 'string', $standard['reporter']);
$quail
->runCheck([
'ac_module_guideline' => $standard['guideline'],
'severity' => $severity,
]);
$results = $quail
->getReport();
$quail
->cleanup();
if (!isset($results['report']) || !is_array($results['report'])) {
$results['report'] = FALSE;
}
return $results;
}
}