From 17d7ee0eeabc9ccd3d3beebfeb78b9e1160bc472 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Mon, 22 Feb 2016 11:45:41 +0000 Subject: [PATCH] MDL-50887 antivirus: Add config getter to base class. Improving architecture to make it testable. --- lib/classes/antivirus/scanner.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/classes/antivirus/scanner.php b/lib/classes/antivirus/scanner.php index 64006fad726..369c48d2db3 100644 --- a/lib/classes/antivirus/scanner.php +++ b/lib/classes/antivirus/scanner.php @@ -51,6 +51,21 @@ abstract class scanner { $this->config = get_config($ref->getNamespaceName()); } + /** + * Config get method. + * + * @param string $property config property to get. + * + * @return mixed + * @throws \coding_exception + */ + public function get_config($property) { + if (property_exists($this->config, $property)) { + return $this->config->$property; + } + throw new \coding_exception('Config property "' . $property . '" doesn\'t exist'); + } + /** * Are the antivirus settings configured? *