Add method to indicate completeness.

This commit is contained in:
James Cole
2018-04-29 18:06:47 +02:00
parent 9646dc439e
commit 7390e20218
4 changed files with 57 additions and 0 deletions

View File

@@ -91,6 +91,22 @@ class BunqPrerequisites implements PrerequisitesInterface
return !$hasApiKey || !$hasServerIP;
}
/**
* Indicate if all prerequisites have been met.
*
* @return bool
*/
public function isComplete(): bool
{
// is complete when user has entered both the API key
// and his IP address.
$hasApiKey = $this->hasApiKey();
$hasServerIP = $this->hasServerIP();
return $hasApiKey && $hasServerIP;
}
/**
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
*

View File

@@ -75,6 +75,17 @@ class FilePrerequisites implements PrerequisitesInterface
return false;
}
/**
* Indicate if all prerequisites have been met.
*
* @return bool
*/
public function isComplete(): bool
{
// has no prerequisites, so always return true.
return true;
}
/**
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
*

View File

@@ -53,6 +53,13 @@ interface PrerequisitesInterface
*/
public function hasPrerequisites(): bool;
/**
* Indicate if all prerequisites have been met.
*
* @return bool
*/
public function isComplete(): bool;
/**
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
*

View File

@@ -87,6 +87,29 @@ class SpectrePrerequisites implements PrerequisitesInterface
return false;
}
/**
* Indicate if all prerequisites have been met.
*
* @return bool
*/
public function isComplete(): bool
{
// return true when user has set the App Id and the Spectre Secret.
$values = [
Preferences::getForUser($this->user, 'spectre_app_id', false),
Preferences::getForUser($this->user, 'spectre_secret', false),
];
$result = true;
/** @var Preference $value */
foreach ($values as $value) {
if (false === $value->data || null === $value->data) {
$result = false;
}
}
return $result;
}
/**
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
*