diff options
Diffstat (limited to 'plugins/CustomDimensions/Dimension/Extractions.php')
m--------- | plugins/CustomDimensions | 0 | ||||
-rw-r--r-- | plugins/CustomDimensions/Dimension/Extractions.php | 47 |
2 files changed, 47 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions deleted file mode 160000 -Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113 diff --git a/plugins/CustomDimensions/Dimension/Extractions.php b/plugins/CustomDimensions/Dimension/Extractions.php new file mode 100644 index 0000000000..acc885f90d --- /dev/null +++ b/plugins/CustomDimensions/Dimension/Extractions.php @@ -0,0 +1,47 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Plugins\CustomDimensions\Dimension; + +use Exception; + +class Extractions +{ + private $extractions = array(); + + public function __construct($extractions) + { + $this->extractions = $extractions; + } + + public function check() + { + if (!is_array($this->extractions)) { + throw new Exception('extractions has to be an array'); + } + + foreach ($this->extractions as $extraction) { + + if (!is_array($extraction)) { + throw new \Exception('Each extraction within extractions has to be an array'); + } + + if (count($extraction) !== 2 + || !array_key_exists('dimension', $extraction) + || !array_key_exists('pattern', $extraction)) { + + throw new \Exception('Each extraction within extractions must have a key "dimension" and "pattern" only'); + } + + $extraction = new Extraction($extraction['dimension'], $extraction['pattern']); + $extraction->check(); + } + } + +}
\ No newline at end of file |