From c6006e40dbc27cf8a4a2c8acc887b5b46620d125 Mon Sep 17 00:00:00 2001 From: Troy Harvey Date: Tue, 13 Dec 2016 14:09:51 -0500 Subject: [PATCH] Use file_exists in version check --- src/HealthVersion.php | 12 ++++-------- tests/HealthVersionTest.php | 2 +- tests/{committest.txt => commit.txt} | 0 3 files changed, 5 insertions(+), 9 deletions(-) rename tests/{committest.txt => commit.txt} (100%) diff --git a/src/HealthVersion.php b/src/HealthVersion.php index f6da190..3eda151 100644 --- a/src/HealthVersion.php +++ b/src/HealthVersion.php @@ -5,15 +5,13 @@ class HealthVersion { - protected $version; - protected $customPath; /** * HealthVersion constructor. * @param string $customPath */ - public function __construct($customPath = __DIR__.'commit.txt') + public function __construct($customPath = __DIR__.'/commit.txt') { $this->customPath = $customPath; } @@ -25,12 +23,10 @@ public function __construct($customPath = __DIR__.'commit.txt') */ public function checkVersion($inputHash) { - $this->version = $inputHash; - - if(!is_file($this->customPath)){ + if (file_exists($this->customPath)) { + return (file_get_contents($this->customPath) == $inputHash); + } else { return false; } - - return (file_get_contents($this->customPath) == $this->version); } } diff --git a/tests/HealthVersionTest.php b/tests/HealthVersionTest.php index ddee893..74d1a16 100644 --- a/tests/HealthVersionTest.php +++ b/tests/HealthVersionTest.php @@ -17,7 +17,7 @@ public function setUp() { parent::setUp(); - $this->correctPathHealthVersion = new HealthVersion("tests/committest.txt"); + $this->correctPathHealthVersion = new HealthVersion('tests/commit.txt'); $this->badPathHealthVersion = new HealthVersion("badpath.txt"); } diff --git a/tests/committest.txt b/tests/commit.txt similarity index 100% rename from tests/committest.txt rename to tests/commit.txt