From 223550d372307a74c016eb133f3f0627784af9c1 Mon Sep 17 00:00:00 2001 From: Brian Gregg Date: Wed, 19 May 2021 16:40:29 -0400 Subject: [PATCH] add User Statistics --- src/Users/UserStatistics.php | 303 +++++++++++++++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 src/Users/UserStatistics.php diff --git a/src/Users/UserStatistics.php b/src/Users/UserStatistics.php new file mode 100644 index 0000000..3f8ceb0 --- /dev/null +++ b/src/Users/UserStatistics.php @@ -0,0 +1,303 @@ +data as $statistic) { + array_push($stats,$statistic); + } + return $stats; + } + + /** + * Get Stats By Type Code. + * + * @return Array of Statistics. + */ + public function getStatsByTypeCode($typeCode) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if ($type_code == $typeCode) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Get Stats by Type Desc. + * + * @return Array of statistics. + */ + public function getStatsByTypeDesc($typeDesc) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if ($type_desc == $typeDesc) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Get Stats by Category Code. + * + * @return Array of Statistics. + */ + public function getStatsByCategoryCode($categoryCode) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if ($category_code == $categoryCode) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Get Stats by Category Desc. + * + * @return Array of Statistics. + */ + public function getStatsByCategoryDesc($categoryDesc) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if ($category_desc == $categoryDesc) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Get Stats by Segment Type. + * + * @return Array of Statistics. + */ + public function getStatsBySegmentType($segmentType) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if ($segment_type == $segmentType) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Search Stats by Note. + * + * @return Array of Statistics. + */ + public function searchStatsByNote($note) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if (preg_match("/$note/i", $statcat_note)) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Search Stats by Type Code. + * + * @return Array of Statistics. + */ + public function searchStatsByTypeCode($typeCode) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if (preg_match("/$typeCode/i", $type_code)) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Search Stats by Type Code. + * + * @return Array of Statistics. + */ + public function searchStatsByTypeDesc($typeDesc) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if (preg_match("/$typeDesc/i", $type_desc)) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Search Stats by Type Code. + * + * @return Array of Statistics. + */ + public function searchStatsByCategoryCode($categoryCode) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if (preg_match("/$categoryCode/i", $category_code)) { + array_push($stats,$statistic); + } + } + return $stats; + } + + /** + * Search Stats by Type Code. + * + * @return Array of Statistics. + */ + public function searchStatsByCategoryDesc($categoryDesc) + { + $stats = array(); + foreach ($this->data as $statistic) { + $statcat_type = $statistic->category_type; + $statcat_cat = $statistic->statistic_category; + $statcat_note = $statistic->statistic_note; + $segment_type = $statistic->segment_type; + + $type_code = $statcat_type->value; + $type_desc = $statcat_type->desc; + $category_code = $statcat_cat->value; + $category_desc = $statcat_cat->desc; + + if (preg_match("/$categoryDesc/i", $category_desc)) { + array_push($stats,$statistic); + } + } + return $stats; + } + + + + /* + public function all($status = 'ACTIVE') + { + $ids = [$this->data->primary_id]; + foreach ($this->data->user_identifier as $identifier) { + if (is_null($status) || $identifier->status == $status) { + $ids[] = $identifier->value; + } + } + + return $ids; + } + */ + +}