From 696863b1d4791000d754242ebcb2b7299beb4d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 24 Oct 2019 18:57:30 +0200 Subject: [PATCH] WIP findBy() --- CONTRIBUTING.md | 7 +++---- src/Exceptions/NotImplementedException.php | 13 +++++++++++++ src/TenantManager.php | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/Exceptions/NotImplementedException.php diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db8cc9d7..82f7aa5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,14 @@ # Contributing ## Code style - -StyleCI will automatically fix code style violations in your pull requests. +StyleCI will flag code style violations in your pull requests. ## Running tests ### With Docker -If you have Docker installed, simply run ./test. When you're done testing, run docker-compose down to shut down the containers. +If you have Docker installed, simply run ./fulltest. When you're done testing, run docker-compose down to shut down the containers. ### Without Docker If you run the tests of this package, please make sure you don't store anything in Redis @ 127.0.0.1:6379 db#14. The contents of this database are flushed everytime the tests are run. -Some tests are run only if the CI, TRAVIS and CONTINUOUS_INTEGRATION environment variables are set to true. This is to avoid things like bloating your MySQL instance with test databases. +Some tests are run only if the `CONTINUOUS_INTEGRATION` or `DOCKER` environment variables are set to true. This is to avoid things like bloating your MySQL instance with test databases. diff --git a/src/Exceptions/NotImplementedException.php b/src/Exceptions/NotImplementedException.php new file mode 100644 index 00000000..d4a85dfc --- /dev/null +++ b/src/Exceptions/NotImplementedException.php @@ -0,0 +1,13 @@ +storage->findByDomain($domain); } + /** + * Find a tenant using an arbitrary key. + * + * @param string $key + * @param mixed $value + * @return Tenant + * @throws TenantCouldNotBeIdentifiedException + * @throws NotImplementedException + */ + public function findBy(string $key, $value): Tenant + { + if (! method_exists($this->storage, 'findBy')) { + throw new NotImplementedException(get_class($this->storage), 'findBy', + "This method was added to storage drivers provided by the package in 2.2.0 and will be part of the StorageDriver contract in 3.0.0." + ); + } + + return $this->storage->find($key, $value); + } + /** * Get all tenants. *