You are here

public function Dimension::__construct in Googalytics - Google Analytics 8

Dimension constructor.

Parameters

int $index: The dimension index.

string $value: The dimension value.

array $fields_object: A set of additional options for the command.

string $tracker_name: The tracker name.

int $priority: The command priority.

Overrides Set::__construct

File

src/AnalyticsCommand/Dimension.php, line 26

Class

Dimension
Class Dimension.

Namespace

Drupal\ga\AnalyticsCommand

Code

public function __construct($index, $value, array $fields_object = [], $tracker_name = NULL, $priority = self::DEFAULT_PRIORITY) {

  // TODO remove this cast in favour of typing in PHP7.
  if (!is_int($index)) {
    if (!is_string($index) || !ctype_digit($index)) {
      throw new \InvalidArgumentException("Dimension index must be an integer between 0 and 199");
    }
    $index = (int) $index;
  }
  if ($index < 0 || $index >= 200) {
    throw new \InvalidArgumentException("Dimension index must be an integer between 0 and 199");
  }
  parent::__construct('dimension' . $index, $value, $fields_object, $tracker_name, $priority);
}