function PerformanceTestRecorder::__construct

Same name in other branches
  1. 10 core/lib/Drupal/Core/Test/PerformanceTestRecorder.php \Drupal\Core\Test\PerformanceTestRecorder::__construct()
  2. 11.x core/lib/Drupal/Core/Test/PerformanceTestRecorder.php \Drupal\Core\Test\PerformanceTestRecorder::__construct()

PerformanceTestRecorder constructor.

Parameters

bool $persistent: Whether to save the record to state.

\Drupal\Core\State\StateInterface|null $state: (optional) The state service for persistent storage. Required if $persistent is TRUE.

File

core/lib/Drupal/Core/Test/PerformanceTestRecorder.php, line 36

Class

PerformanceTestRecorder
Records the number of times specific events occur.

Namespace

Drupal\Core\Test

Code

public function __construct(bool $persistent, ?StateInterface $state) {
    if ($persistent && !$state) {
        throw new \InvalidArgumentException('If $persistent is TRUE then $state must be set');
    }
    $this->state = $state;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.