From b469e9f6fb83758ad91b8e41d81319ab3a73f098 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 1 Dec 2014 21:47:22 +0100 Subject: introduce dependency analyzer to take care of app dependencies some more unit tests on xml info parser --- lib/private/app/dependencyanalyzer.php | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lib/private/app/dependencyanalyzer.php (limited to 'lib/private/app/dependencyanalyzer.php') diff --git a/lib/private/app/dependencyanalyzer.php b/lib/private/app/dependencyanalyzer.php new file mode 100644 index 00000000000..c76181926e2 --- /dev/null +++ b/lib/private/app/dependencyanalyzer.php @@ -0,0 +1,58 @@ +system = $system; + $this->l = $l; + $this->missing = array(); + $this->dependencies = array(); + if (array_key_exists('dependencies', $app)) { + $this->dependencies = $app['dependencies']; + } + } + + /** + * @param array $app + * @returns array of missing dependencies + */ + public function analyze() { + $this->analysePhpVersion(); + return $this->missing; + } + + private function analysePhpVersion() { + if (!array_key_exists('php', $this->dependencies)) { + return; + } + + if (array_key_exists('min-version', $this->dependencies['php'])) { + $minVersion = $this->dependencies['php']['min-version']; + if (version_compare($this->system->getPhpVersion(), $minVersion, '<')) { + $this->missing[] = (string)$this->l->t('PHP %s or higher is required.', $minVersion); + } + } + if (array_key_exists('max-version', $this->dependencies['php'])) { + $maxVersion = $this->dependencies['php']['max-version']; + if (version_compare($this->system->getPhpVersion(), $maxVersion, '>')) { + $this->missing[] = (string)$this->l->t('PHP with a version less then %s is required.', $maxVersion); + } + } + } + +} -- cgit v1.2.3