diff --git a/src/Configuration.php b/src/Configuration.php index a10434e..4f09bee 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -60,9 +60,4 @@ class Configuration { return $this->stateFile; } - - public function isOpen(): bool - { - return file_exists($this->stateFile); - } } diff --git a/src/ReadableState.php b/src/ReadableState.php new file mode 100644 index 0000000..0c5450b --- /dev/null +++ b/src/ReadableState.php @@ -0,0 +1,13 @@ +config = $config; + } + + /** + * Check whether the FooBar is open + * + * @return bool true if the FooBar is open. + */ + public function isOpen(): bool + { + return file_exists($this->config->stateFile()); + } + + /** + * Toggle the current state of the FooBar. + * + * @return bool the new state of the FooBar. + */ + public function toggle(): bool + { + if ($this->isOpen()) { + unlink($this->config->stateFile()); + return false; + } else { + touch($this->config->stateFile()); + return true; + } + } +}