From d4c2d10fe38e8d6556e42f7c14db8fa59ba12834 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 27 Jul 2021 15:19:41 +0200 Subject: [PATCH] chg: [internal] Convert array to const --- app/Model/Attribute.php | 26 +++++++++++++------------- app/Model/Correlation.php | 8 ++++---- app/Model/Feed.php | 4 ++-- app/Model/ShadowAttribute.php | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index ca58f2e29..4d0ccda40 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -89,17 +89,17 @@ class Attribute extends AppModel const UPLOAD_DEFINITIONS = ['attachment']; // skip Correlation for the following types - public $nonCorrelatingTypes = array( - 'comment', - 'http-method', - 'aba-rtn', - 'gender', - 'counter', - 'port', - 'nationality', - 'cortex', - 'boolean', - 'anonymised' + const NON_CORRELATING_TYPES = array( + 'comment', + 'http-method', + 'aba-rtn', + 'gender', + 'counter', + 'port', + 'nationality', + 'cortex', + 'boolean', + 'anonymised' ); const PRIMARY_ONLY_CORRELATING_TYPES = array( @@ -1695,7 +1695,7 @@ class Attribute extends AppModel 'conditions' => [ 'OR' => $or, 'NOT' => [ - 'Attribute.type' => $this->nonCorrelatingTypes, + 'Attribute.type' => Attribute::NON_CORRELATING_TYPES, ], 'Attribute.disable_correlation' => 0, ], @@ -2304,7 +2304,7 @@ class Attribute extends AppModel 'Attribute.deleted' => 0, 'Attribute.disable_correlation' => 0, 'NOT' => array( - 'Attribute.type' => $this->nonCorrelatingTypes, + 'Attribute.type' => Attribute::NON_CORRELATING_TYPES, ), ); if ($attributeId) { diff --git a/app/Model/Correlation.php b/app/Model/Correlation.php index 8f8f8ac89..f7499efd9 100644 --- a/app/Model/Correlation.php +++ b/app/Model/Correlation.php @@ -82,7 +82,7 @@ class Correlation extends AppModel 'conditions' => [ 'AND' => $extraConditions, 'NOT' => [ - 'Attribute.type' => $this->Attribute->nonCorrelatingTypes, + 'Attribute.type' => Attribute::NON_CORRELATING_TYPES, ], 'Attribute.disable_correlation' => 0, 'Event.disable_correlation' => 0, @@ -117,7 +117,7 @@ class Correlation extends AppModel ] ], 'NOT' => [ - 'Attribute.type' => $this->Attribute->nonCorrelatingTypes, + 'Attribute.type' => Attribute::NON_CORRELATING_TYPES, ], 'Attribute.disable_correlation' => 0, 'Event.disable_correlation' => 0, @@ -269,7 +269,7 @@ class Correlation extends AppModel return true; } // Don't do any correlation if the type is a non correlating type - if (in_array($a['type'], $this->Attribute->nonCorrelatingTypes)) { + if (in_array($a['type'], Attribute::NON_CORRELATING_TYPES, true)) { return true; } if ($this->__preventExcludedCorrelations($a)) { @@ -306,7 +306,7 @@ class Correlation extends AppModel ], 'NOT' => [ 'Attribute.event_id' => $a['event_id'], - 'Attribute.type' => $this->Attribute->nonCorrelatingTypes, + 'Attribute.type' => Attribute::NON_CORRELATING_TYPES, ], 'Attribute.disable_correlation' => 0, 'Event.disable_correlation' => 0, diff --git a/app/Model/Feed.php b/app/Model/Feed.php index 69818afd9..f26249201 100644 --- a/app/Model/Feed.php +++ b/app/Model/Feed.php @@ -381,7 +381,7 @@ class Feed extends AppModel $redisResultToAttributePosition = []; foreach ($attributes as $k => $attribute) { - if (in_array($attribute['type'], $this->Attribute->nonCorrelatingTypes, true)) { + if (in_array($attribute['type'], Attribute::NON_CORRELATING_TYPES, true)) { continue; // attribute type is not correlateable } if (!empty($attribute['disable_correlation'])) { @@ -1313,7 +1313,7 @@ class Feed extends AppModel $this->Attribute = ClassRegistry::init('Attribute'); $pipe = $redis->multi(Redis::PIPELINE); foreach ($event['Event']['Attribute'] as $attribute) { - if (!in_array($attribute['type'], $this->Attribute->nonCorrelatingTypes)) { + if (!in_array($attribute['type'], Attribute::NON_CORRELATING_TYPES, true)) { if (in_array($attribute['type'], $this->Attribute->getCompositeTypes())) { $value = explode('|', $attribute['value']); if (in_array($attribute['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true)) { diff --git a/app/Model/ShadowAttribute.php b/app/Model/ShadowAttribute.php index c430a2ded..598b56be4 100644 --- a/app/Model/ShadowAttribute.php +++ b/app/Model/ShadowAttribute.php @@ -210,7 +210,7 @@ class ShadowAttribute extends AppModel if (isset($sa['ShadowAttribute'])) { $sa = $sa['ShadowAttribute']; } - if (in_array($sa['type'], $this->Attribute->nonCorrelatingTypes)) { + if (in_array($sa['type'], Attribute::NON_CORRELATING_TYPES, true)) { return; } $this->ShadowAttributeCorrelation = ClassRegistry::init('ShadowAttributeCorrelation'); @@ -228,7 +228,7 @@ class ShadowAttribute extends AppModel 'Attribute.value1' => $cV, 'Attribute.value2' => $cV ), - 'Attribute.type !=' => $this->Attribute->nonCorrelatingTypes, + 'Attribute.type !=' => Attribute::NON_CORRELATING_TYPES, 'Attribute.deleted' => 0, 'Attribute.event_id !=' => $sa['event_id'] ),