diff options
author | Matthias Held <ilovemilk@wusa.io> | 2018-09-10 23:58:22 +0300 |
---|---|---|
committer | Matthias Held <ilovemilk@wusa.io> | 2018-09-10 23:58:22 +0300 |
commit | 7c2ba742257689eba6704240917c1979b5033d12 (patch) | |
tree | b18eb940465a430e2e358738e52b79b552fe3749 | |
parent | 8b949ae0784f06d73d8e4ff63c9454f54b8c2d82 (diff) |
Use JsonSerializable
Signed-off-by: Matthias Held <matthias.held@uni-konstanz.de>
-rw-r--r-- | lib/Analyzer/EntropyFunnellingResult.php | 13 | ||||
-rw-r--r-- | lib/Analyzer/SequenceResult.php | 13 | ||||
-rw-r--r-- | lib/Controller/MonitoringController.php | 2 |
3 files changed, 7 insertions, 21 deletions
diff --git a/lib/Analyzer/EntropyFunnellingResult.php b/lib/Analyzer/EntropyFunnellingResult.php index a3c7325..8b8c238 100644 --- a/lib/Analyzer/EntropyFunnellingResult.php +++ b/lib/Analyzer/EntropyFunnellingResult.php @@ -21,7 +21,7 @@ namespace OCA\RansomwareDetection\Analyzer; -class EntropyFunnellingResult +class EntropyFunnellingResult implements \JsonSerializable { /** @var float */ protected $medianWritten; @@ -141,15 +141,8 @@ class EntropyFunnellingResult $this->entropyFunnelling = $entropyFunnelling; } - public function toArray() + public function jsonSerialize() { - $var = get_object_vars($this); - foreach ($var as &$value) { - if (is_object($value) && method_exists($value, 'toArray')) { - $value = $value->toArray(); - } - } - - return $var; + return get_object_vars($this); } } diff --git a/lib/Analyzer/SequenceResult.php b/lib/Analyzer/SequenceResult.php index b5fce8b..6994b73 100644 --- a/lib/Analyzer/SequenceResult.php +++ b/lib/Analyzer/SequenceResult.php @@ -21,7 +21,7 @@ namespace OCA\RansomwareDetection\Analyzer; -class SequenceResult +class SequenceResult implements \JsonSerializable { /** @var int */ protected $sequenceId; @@ -164,15 +164,8 @@ class SequenceResult $this->sequence = $sequence; } - public function toArray() + public function jsonSerialize() { - $var = get_object_vars($this); - foreach ($var as &$value) { - if (is_object($value) && method_exists($value, 'toArray')) { - $value = $value->toArray(); - } - } - - return $var; + return get_object_vars($this); } } diff --git a/lib/Controller/MonitoringController.php b/lib/Controller/MonitoringController.php index 1abda78..b309361 100644 --- a/lib/Controller/MonitoringController.php +++ b/lib/Controller/MonitoringController.php @@ -166,7 +166,7 @@ class MonitoringController extends OCSController foreach ($sequences as $sequenceId => $sequence) { if (sizeof($sequence) >= $this->config->getAppValue(Application::APP_ID, 'minimum_sequence_length', 0)) { - $result[] = $this->sequenceAnalyzer->analyze($sequenceId, $sequence)->toArray(); + $result[] = $this->sequenceAnalyzer->analyze($sequenceId, $sequence); } } |