Skip to content

Commit

Permalink
Merge pull request #3 from generationtux/OP-434-version-file-exists
Browse files Browse the repository at this point in the history
OP-434 Use file_exists in version check
  • Loading branch information
colanconnon authored Dec 13, 2016
2 parents 420b7c8 + c6006e4 commit d32cc5a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/HealthVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion tests/HealthVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
File renamed without changes.

0 comments on commit d32cc5a

Please sign in to comment.