class Metric in Googalytics - Google Analytics 8
Class Dimension.
@package Drupal\ga\AnalyticsCommand
Hierarchy
- class \Drupal\ga\AnalyticsCommand\Generic implements DrupalSettingCommandsInterface uses DrupalSettingCommandsTrait
Expanded class hierarchy of Metric
2 files declare their use of Metric
- AnalyticsSubscriber.php in modules/
ga_tokens/ src/ EventSubscriber/ AnalyticsSubscriber.php - MetricTest.php in tests/
src/ Unit/ AnalyticsCommand/ MetricTest.php
1 string reference to 'Metric'
- ga_tokens.schema.yml in modules/
ga_tokens/ config/ schema/ ga_tokens.schema.yml - modules/ga_tokens/config/schema/ga_tokens.schema.yml
File
- src/
AnalyticsCommand/ Metric.php, line 10
Namespace
Drupal\ga\AnalyticsCommandView source
class Metric extends Set {
/**
* Dimension constructor.
*
* @param int $index
* The metric index.
* @param int|float $value
* The metric value.
* @param array $fields_object
* A set of additional options for the command.
* @param string $tracker_name
* The tracker name.
* @param int $priority
* The command priority.
*/
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("Metric index must be an integer between 0 and 199");
}
$index = (int) $index;
}
if ($index < 0 || $index >= 200) {
throw new \InvalidArgumentException("Metric index must be an integer between 0 and 199");
}
if (!is_int($value) || !is_float($value)) {
if (!is_numeric($value)) {
throw new \InvalidArgumentException("Metric value must be numeric");
}
if (ctype_digit($value)) {
$value = (int) $value;
}
else {
$value = (double) $value;
}
}
parent::__construct('metric' . $index, $value, $fields_object, $tracker_name, $priority);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalSettingCommandsTrait:: |
protected | property | Priority integer. | |
DrupalSettingCommandsTrait:: |
public | function | An integer value for sorting by priority. | |
Generic:: |
protected | property | The command name. | |
Generic:: |
protected | property | A map of values for the command's fieldsObject parameter. | |
Generic:: |
protected | property | The name of the tracker for this command. | |
Generic:: |
public | function | Get the command name. | |
Generic:: |
public | function | Get the map of values for the command's fieldsObject parameter. | |
Generic:: |
public | function | The tracker this command will be applied to, if specified. | |
Metric:: |
public | function |
Dimension constructor. Overrides Set:: |
|
Set:: |
protected | property | The setting key. | |
Set:: |
protected | property | The setting value. | |
Set:: |
constant |
Overrides Generic:: |
||
Set:: |
public | function |
An array of commands to be sent to Google Analytics. Overrides Generic:: |
|
Set:: |
public | function | Get the setting key. | |
Set:: |
public | function | Get the setting value. |