From 6adac1bff018e0de7cde7e0349ef81f204f51931 Mon Sep 17 00:00:00 2001 From: Emanuele Minotto Date: Tue, 5 Jan 2016 01:34:24 +0100 Subject: [PATCH] moved to a more structured hierarchy --- lib/Doctrine/KeyValueStore/Configuration.php | 4 ++- .../StorageException.php => Exception.php} | 6 ++--- .../Exception.php} | 10 +++---- .../Exception/InvalidArgumentException.php | 27 +++++++++++++++++++ .../{ => Exception}/NotFoundException.php | 4 +-- .../Exception/RuntimeException.php | 27 +++++++++++++++++++ .../KeyValueStore/Id/CompositeIdHandler.php | 4 +-- .../Id/Exception/InvalidArgumentException.php | 27 +++++++++++++++++++ .../Mapping/AnnotationDriver.php | 2 +- .../Mapping/ClassMetadataFactory.php | 4 +-- .../Exception/InvalidArgumentException.php | 27 +++++++++++++++++++ .../KeyValueStore/Mapping/XmlDriver.php | 4 +-- .../KeyValueStore/Mapping/YamlDriver.php | 2 +- .../Query/Exception/RuntimeException.php | 27 +++++++++++++++++++ .../KeyValueStore/Query/RangeQuery.php | 2 +- .../Storage/AzureSdkTableStorage.php | 12 ++++----- .../Storage/CassandraStorage.php | 2 +- .../KeyValueStore/Storage/CouchDbStorage.php | 4 +-- .../Storage/CouchbaseStorage.php | 2 +- .../KeyValueStore/Storage/DBALStorage.php | 2 +- .../KeyValueStore/Storage/DynamoDbStorage.php | 2 +- .../Storage/Exception/Exception.php | 27 +++++++++++++++++++ .../Exception/InvalidArgumentException.php | 27 +++++++++++++++++++ .../Storage/Exception/RuntimeException.php | 27 +++++++++++++++++++ .../KeyValueStore/Storage/MongoDbStorage.php | 6 ++--- .../KeyValueStore/Storage/RedisStorage.php | 2 +- .../KeyValueStore/Storage/RiakStorage.php | 2 +- .../KeyValueStore/Storage/SimpleDbStorage.php | 4 +-- .../KeyValueStore/Storage/Storage.php | 2 +- lib/Doctrine/KeyValueStore/UnitOfWork.php | 12 ++++----- .../Tests/KeyValueStore/ConfigurationTest.php | 6 ++++- .../Functional/Storage/AzureSdkTableTest.php | 2 +- .../Functional/Storage/CassandraTest.php | 2 +- .../Storage/WindowsAzureTableTest.php | 2 +- .../KeyValueStore/Storage/RiakStorageTest.php | 2 +- 35 files changed, 271 insertions(+), 53 deletions(-) rename lib/Doctrine/KeyValueStore/{Storage/StorageException.php => Exception.php} (87%) rename lib/Doctrine/KeyValueStore/{KeyValueStoreException.php => Exception/Exception.php} (79%) create mode 100644 lib/Doctrine/KeyValueStore/Exception/InvalidArgumentException.php rename lib/Doctrine/KeyValueStore/{ => Exception}/NotFoundException.php (91%) create mode 100644 lib/Doctrine/KeyValueStore/Exception/RuntimeException.php create mode 100644 lib/Doctrine/KeyValueStore/Id/Exception/InvalidArgumentException.php create mode 100644 lib/Doctrine/KeyValueStore/Mapping/Exception/InvalidArgumentException.php create mode 100644 lib/Doctrine/KeyValueStore/Query/Exception/RuntimeException.php create mode 100644 lib/Doctrine/KeyValueStore/Storage/Exception/Exception.php create mode 100644 lib/Doctrine/KeyValueStore/Storage/Exception/InvalidArgumentException.php create mode 100644 lib/Doctrine/KeyValueStore/Storage/Exception/RuntimeException.php diff --git a/lib/Doctrine/KeyValueStore/Configuration.php b/lib/Doctrine/KeyValueStore/Configuration.php index 3caaaa9..732b65f 100644 --- a/lib/Doctrine/KeyValueStore/Configuration.php +++ b/lib/Doctrine/KeyValueStore/Configuration.php @@ -46,7 +46,9 @@ class Configuration public function getMappingDriverImpl() { if (! isset($this->config['mappingDriver'])) { - throw KeyValueStoreException::mappingDriverMissing(); + throw new Exception\Exception( + 'No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()' + ); } return $this->config['mappingDriver']; diff --git a/lib/Doctrine/KeyValueStore/Storage/StorageException.php b/lib/Doctrine/KeyValueStore/Exception.php similarity index 87% rename from lib/Doctrine/KeyValueStore/Storage/StorageException.php rename to lib/Doctrine/KeyValueStore/Exception.php index 3f8132e..7e5668a 100644 --- a/lib/Doctrine/KeyValueStore/Storage/StorageException.php +++ b/lib/Doctrine/KeyValueStore/Exception.php @@ -18,10 +18,8 @@ * . */ -namespace Doctrine\KeyValueStore\Storage; +namespace Doctrine\KeyValueStore; -use Doctrine\KeyValueStore\KeyValueStoreException; - -class StorageException extends KeyValueStoreException +interface Exception { } diff --git a/lib/Doctrine/KeyValueStore/KeyValueStoreException.php b/lib/Doctrine/KeyValueStore/Exception/Exception.php similarity index 79% rename from lib/Doctrine/KeyValueStore/KeyValueStoreException.php rename to lib/Doctrine/KeyValueStore/Exception/Exception.php index d5d503a..143d4b5 100644 --- a/lib/Doctrine/KeyValueStore/KeyValueStoreException.php +++ b/lib/Doctrine/KeyValueStore/Exception/Exception.php @@ -18,12 +18,10 @@ * . */ -namespace Doctrine\KeyValueStore; +namespace Doctrine\KeyValueStore\Exception; -class KeyValueStoreException extends \Exception +use Doctrine\KeyValueStore\Exception as BaseException; + +class Exception extends \Exception implements BaseException { - public static function mappingDriverMissing() - { - return new self('No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()'); - } } diff --git a/lib/Doctrine/KeyValueStore/Exception/InvalidArgumentException.php b/lib/Doctrine/KeyValueStore/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..c7e7378 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Exception/InvalidArgumentException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Exception; + +use Doctrine\KeyValueStore\Exception as BaseException; + +class InvalidArgumentException extends \InvalidArgumentException implements BaseException +{ +} diff --git a/lib/Doctrine/KeyValueStore/NotFoundException.php b/lib/Doctrine/KeyValueStore/Exception/NotFoundException.php similarity index 91% rename from lib/Doctrine/KeyValueStore/NotFoundException.php rename to lib/Doctrine/KeyValueStore/Exception/NotFoundException.php index 949b0eb..23c6e52 100644 --- a/lib/Doctrine/KeyValueStore/NotFoundException.php +++ b/lib/Doctrine/KeyValueStore/Exception/NotFoundException.php @@ -18,8 +18,8 @@ * . */ -namespace Doctrine\KeyValueStore; +namespace Doctrine\KeyValueStore\Exception; -class NotFoundException extends KeyValueStoreException +class NotFoundException extends Exception { } diff --git a/lib/Doctrine/KeyValueStore/Exception/RuntimeException.php b/lib/Doctrine/KeyValueStore/Exception/RuntimeException.php new file mode 100644 index 0000000..18ccd59 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Exception/RuntimeException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Exception; + +use Doctrine\KeyValueStore\Exception as BaseException; + +class RuntimeException extends \RuntimeException implements BaseException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Id/CompositeIdHandler.php b/lib/Doctrine/KeyValueStore/Id/CompositeIdHandler.php index 8ed1b56..3c2bf79 100644 --- a/lib/Doctrine/KeyValueStore/Id/CompositeIdHandler.php +++ b/lib/Doctrine/KeyValueStore/Id/CompositeIdHandler.php @@ -29,12 +29,12 @@ public function normalizeId(ClassMetadata $metadata, $key) if (! $metadata->isCompositeKey && ! is_array($key)) { $id = [$metadata->identifier[0] => $key]; } elseif (! is_array($key)) { - throw new \InvalidArgumentException('Array of identifier key-value pairs is expected!'); + throw new Exception\InvalidArgumentException('Array of identifier key-value pairs is expected!'); } else { $id = []; foreach ($metadata->identifier as $field) { if (! isset($key[$field])) { - throw new \InvalidArgumentException( + throw new Exception\InvalidArgumentException( "Missing identifier field $field in request for the primary key." ); } diff --git a/lib/Doctrine/KeyValueStore/Id/Exception/InvalidArgumentException.php b/lib/Doctrine/KeyValueStore/Id/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..81688c4 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Id/Exception/InvalidArgumentException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Id\Exception; + +use Doctrine\KeyValueStore\Exception\InvalidArgumentException as BaseInvalidArgumentException; + +class InvalidArgumentException extends BaseInvalidArgumentException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php b/lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php index e664c1b..c77d0d2 100644 --- a/lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php +++ b/lib/Doctrine/KeyValueStore/Mapping/AnnotationDriver.php @@ -60,7 +60,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) $entityAnnot = $this->reader->getClassAnnotation($class, 'Doctrine\KeyValueStore\Mapping\Annotations\Entity'); if (! $entityAnnot) { - throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); + throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); } $metadata->storageName = $entityAnnot->storageName; diff --git a/lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php b/lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php index a6dbf22..62990b1 100644 --- a/lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/KeyValueStore/Mapping/ClassMetadataFactory.php @@ -46,7 +46,7 @@ protected function initialize() protected function getFqcnFromAlias($namespaceAlias, $simpleClassName) { - throw new \InvalidArgumentException('aliasing is not supported.'); + throw new Exception\InvalidArgumentException('aliasing is not supported.'); } protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents) @@ -64,7 +64,7 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS } if (! $class->identifier) { - throw new \InvalidArgumentException('Class ' . $class->name . ' has no identifier.'); + throw new Exception\InvalidArgumentException('Class ' . $class->name . ' has no identifier.'); } } diff --git a/lib/Doctrine/KeyValueStore/Mapping/Exception/InvalidArgumentException.php b/lib/Doctrine/KeyValueStore/Mapping/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..958e214 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Mapping/Exception/InvalidArgumentException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Mapping\Exception; + +use Doctrine\KeyValueStore\Exception\InvalidArgumentException as BaseInvalidArgumentException; + +class InvalidArgumentException extends BaseInvalidArgumentException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Mapping/XmlDriver.php b/lib/Doctrine/KeyValueStore/Mapping/XmlDriver.php index 4fd24a2..e436fb8 100644 --- a/lib/Doctrine/KeyValueStore/Mapping/XmlDriver.php +++ b/lib/Doctrine/KeyValueStore/Mapping/XmlDriver.php @@ -70,11 +70,11 @@ public function loadMetadataForClass($className, CommonClassMetadata $metadata) try { $xmlRoot = $this->getElement($className); } catch (MappingException $exception) { - throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); + throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); } if ($xmlRoot->getName() != 'entity') { - throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); + throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); } $class = new \ReflectionClass($className); diff --git a/lib/Doctrine/KeyValueStore/Mapping/YamlDriver.php b/lib/Doctrine/KeyValueStore/Mapping/YamlDriver.php index 666dfde..ed7cad7 100644 --- a/lib/Doctrine/KeyValueStore/Mapping/YamlDriver.php +++ b/lib/Doctrine/KeyValueStore/Mapping/YamlDriver.php @@ -62,7 +62,7 @@ public function loadMetadataForClass($className, CommonClassMetadata $metadata) try { $element = $this->getElement($className); } catch (MappingException $exception) { - throw new \InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); + throw new Exception\InvalidArgumentException($metadata->name . ' is not a valid key-value-store entity.'); } $class = new \ReflectionClass($className); diff --git a/lib/Doctrine/KeyValueStore/Query/Exception/RuntimeException.php b/lib/Doctrine/KeyValueStore/Query/Exception/RuntimeException.php new file mode 100644 index 0000000..29b7a9a --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Query/Exception/RuntimeException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Query\Exception; + +use Doctrine\KeyValueStore\Exception\RuntimeException as BaseRuntimeException; + +class RuntimeException extends BaseRuntimeException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Query/RangeQuery.php b/lib/Doctrine/KeyValueStore/Query/RangeQuery.php index c0daa4f..769c17a 100644 --- a/lib/Doctrine/KeyValueStore/Query/RangeQuery.php +++ b/lib/Doctrine/KeyValueStore/Query/RangeQuery.php @@ -209,7 +209,7 @@ public function execute() $storage = $this->em->unwrap(); if (! $storage instanceof RangeQueryStorage) { - throw new \RuntimeException( + throw new Exception\RuntimeException( 'The storage backend ' . $storage->getName() . ' does not support range queries.' ); } diff --git a/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php b/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php index 51031f1..4a83688 100644 --- a/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/AzureSdkTableStorage.php @@ -20,7 +20,7 @@ namespace Doctrine\KeyValueStore\Storage; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; use Doctrine\KeyValueStore\Query\RangeQuery; use Doctrine\KeyValueStore\Query\RangeQueryStorage; use WindowsAzure\Common\ServiceException; @@ -82,7 +82,7 @@ public function insert($storageName, $key, array $data) if ($e->getCode() == 404) { $this->client->createTable($storageName); } else { - throw new StorageException( + throw new Exception\Exception( 'Could not save entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(), $e->getCode(), $e @@ -101,7 +101,7 @@ public function update($storageName, $key, array $data) try { $this->client->updateEntity($storageName, $entity); } catch (ServiceException $e) { - throw new StorageException( + throw new Exception\Exception( 'Could not update entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(), $e->getCode(), $e @@ -119,7 +119,7 @@ public function delete($storageName, $key) try { $this->client->deleteEntity($storageName, $partitonKey, $rowKey); } catch (ServiceException $e) { - throw new StorageException( + throw new Exception\Exception( 'Could not delete entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(), $e->getCode(), $e @@ -140,7 +140,7 @@ public function find($storageName, $key) if ($e->getCode() === 404) { throw new NotFoundException(); } else { - throw new StorageException( + throw new Exception\Exception( 'Could not find entity in table, WindowsAzure SDK client reported error: ' . $e->getMessage(), $e->getCode(), $e @@ -185,7 +185,7 @@ public function executeRangeQuery(RangeQuery $query, $storageName, $key, \Closur foreach ($query->getConditions() as $condition) { if (! in_array($condition[0], ['eq', 'neq', 'le', 'lt', 'ge', 'gt'])) { - throw new \InvalidArgumentException( + throw new Exception\InvalidArgumentException( 'Windows Azure Table only supports eq, neq, le, lt, ge, gt as conditions.' ); } diff --git a/lib/Doctrine/KeyValueStore/Storage/CassandraStorage.php b/lib/Doctrine/KeyValueStore/Storage/CassandraStorage.php index 59f3e44..dc443dc 100644 --- a/lib/Doctrine/KeyValueStore/Storage/CassandraStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/CassandraStorage.php @@ -22,7 +22,7 @@ use Cassandra\ExecutionOptions; use Cassandra\Session; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * Cassandra Storage Engine for KeyValueStore. diff --git a/lib/Doctrine/KeyValueStore/Storage/CouchDbStorage.php b/lib/Doctrine/KeyValueStore/Storage/CouchDbStorage.php index a1cafc2..7b0d9d0 100644 --- a/lib/Doctrine/KeyValueStore/Storage/CouchDbStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/CouchDbStorage.php @@ -116,7 +116,7 @@ public function getName() /** * @param string $storageName * @param array|string $key - * + * * @return string */ private function flattenKey($storageName, $key) @@ -128,7 +128,7 @@ private function flattenKey($storageName, $key) } if (! is_array($key)) { - throw new \InvalidArgumentException('The key should be a string or a flat array.'); + throw new Exception\InvalidArgumentException('The key should be a string or a flat array.'); } foreach ($key as $property => $value) { diff --git a/lib/Doctrine/KeyValueStore/Storage/CouchbaseStorage.php b/lib/Doctrine/KeyValueStore/Storage/CouchbaseStorage.php index 4fca169..874ca5b 100644 --- a/lib/Doctrine/KeyValueStore/Storage/CouchbaseStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/CouchbaseStorage.php @@ -20,7 +20,7 @@ namespace Doctrine\KeyValueStore\Storage; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * @author Simon Schick diff --git a/lib/Doctrine/KeyValueStore/Storage/DBALStorage.php b/lib/Doctrine/KeyValueStore/Storage/DBALStorage.php index 93007fa..6788636 100644 --- a/lib/Doctrine/KeyValueStore/Storage/DBALStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/DBALStorage.php @@ -21,7 +21,7 @@ namespace Doctrine\KeyValueStore\Storage; use Doctrine\DBAL\Connection; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * Relational databased backed system. diff --git a/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php b/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php index 5fd366b..005d781 100644 --- a/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/DynamoDbStorage.php @@ -23,7 +23,7 @@ use Aws\DynamoDb\DynamoDbClient; use Aws\DynamoDb\Exception\ResourceNotFoundException; use Aws\DynamoDb\Iterator\ItemIterator; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * DyanmoDb storage diff --git a/lib/Doctrine/KeyValueStore/Storage/Exception/Exception.php b/lib/Doctrine/KeyValueStore/Storage/Exception/Exception.php new file mode 100644 index 0000000..5a5d5f5 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Storage/Exception/Exception.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Storage\Exception; + +use Doctrine\KeyValueStore\Exception\Exception as BaseException; + +class Exception extends BaseException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Storage/Exception/InvalidArgumentException.php b/lib/Doctrine/KeyValueStore/Storage/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..1a88850 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Storage/Exception/InvalidArgumentException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Storage\Exception; + +use Doctrine\KeyValueStore\Exception\InvalidArgumentException as BaseInvalidArgumentException; + +class InvalidArgumentException extends BaseInvalidArgumentException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Storage/Exception/RuntimeException.php b/lib/Doctrine/KeyValueStore/Storage/Exception/RuntimeException.php new file mode 100644 index 0000000..bffed93 --- /dev/null +++ b/lib/Doctrine/KeyValueStore/Storage/Exception/RuntimeException.php @@ -0,0 +1,27 @@ +. + */ + +namespace Doctrine\KeyValueStore\Storage\Exception; + +use Doctrine\KeyValueStore\Exception\RuntimeException as BaseRuntimeException; + +class RuntimeException extends BaseRuntimeException +{ +} diff --git a/lib/Doctrine/KeyValueStore/Storage/MongoDbStorage.php b/lib/Doctrine/KeyValueStore/Storage/MongoDbStorage.php index a9ba59a..f70f24b 100644 --- a/lib/Doctrine/KeyValueStore/Storage/MongoDbStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/MongoDbStorage.php @@ -20,7 +20,7 @@ namespace Doctrine\KeyValueStore\Storage; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * MongoDb storage @@ -71,10 +71,10 @@ public function initialize() } if (empty($this->dbOptions['database'])) { - throw new \RuntimeException('The option "database" must be set'); + throw new Exception\RuntimeException('The option "database" must be set'); } if (empty($this->dbOptions['collection'])) { - throw new \RuntimeException('The option "collection" must be set'); + throw new Exception\RuntimeException('The option "collection" must be set'); } $this->collection = $this diff --git a/lib/Doctrine/KeyValueStore/Storage/RedisStorage.php b/lib/Doctrine/KeyValueStore/Storage/RedisStorage.php index 84fa7f9..37de966 100644 --- a/lib/Doctrine/KeyValueStore/Storage/RedisStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/RedisStorage.php @@ -20,7 +20,7 @@ namespace Doctrine\KeyValueStore\Storage; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * @author Marcel Araujo diff --git a/lib/Doctrine/KeyValueStore/Storage/RiakStorage.php b/lib/Doctrine/KeyValueStore/Storage/RiakStorage.php index 6e04700..db7c29c 100644 --- a/lib/Doctrine/KeyValueStore/Storage/RiakStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/RiakStorage.php @@ -20,7 +20,7 @@ namespace Doctrine\KeyValueStore\Storage; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\NotFoundException; use Riak\Client; /** diff --git a/lib/Doctrine/KeyValueStore/Storage/SimpleDbStorage.php b/lib/Doctrine/KeyValueStore/Storage/SimpleDbStorage.php index 730c21b..3f182d3 100644 --- a/lib/Doctrine/KeyValueStore/Storage/SimpleDbStorage.php +++ b/lib/Doctrine/KeyValueStore/Storage/SimpleDbStorage.php @@ -23,8 +23,8 @@ use Aws\SimpleDb\Exception\NoSuchDomainException; use Aws\SimpleDb\Exception\SimpleDbException; use Aws\SimpleDb\SimpleDbClient; -use Doctrine\KeyValueStore\KeyValueStoreException; -use Doctrine\KeyValueStore\NotFoundException; +use Doctrine\KeyValueStore\Exception\Exception as KeyValueStoreException; +use Doctrine\KeyValueStore\Exception\NotFoundException; /** * SimpleDb storage diff --git a/lib/Doctrine/KeyValueStore/Storage/Storage.php b/lib/Doctrine/KeyValueStore/Storage/Storage.php index 75874f1..a5156ac 100644 --- a/lib/Doctrine/KeyValueStore/Storage/Storage.php +++ b/lib/Doctrine/KeyValueStore/Storage/Storage.php @@ -99,7 +99,7 @@ public function delete($storageName, $key); * @param string $storageName * @param array|string $key * - * @throws Doctrine\KeyValueStore\NotFoundException When data with key is not found. + * @throws Doctrine\KeyValueStore\Exception\NotFoundException When data with key is not found. * * @return array */ diff --git a/lib/Doctrine/KeyValueStore/UnitOfWork.php b/lib/Doctrine/KeyValueStore/UnitOfWork.php index 91fa7ed..f776771 100644 --- a/lib/Doctrine/KeyValueStore/UnitOfWork.php +++ b/lib/Doctrine/KeyValueStore/UnitOfWork.php @@ -92,7 +92,7 @@ public function reconstititute($className, $key) $data = $this->storageDriver->find($class->storageName, $id); if (! $data) { - throw new NotFoundException(); + throw new Exception\NotFoundException(); } return $this->createEntity($class, $id, $data); @@ -102,7 +102,7 @@ public function createEntity($class, $id, $data) { if (isset($data['php_class'])) { if ($data['php_class'] !== $class->name && ! is_subclass_of($data['php_class'], $class->name)) { - throw new \RuntimeException( + throw new Exception\RuntimeException( "Row is of class '" . $data['php_class'] . "' which is not a subtype of expected " . $class->name ); } @@ -184,13 +184,13 @@ public function scheduleForInsert($object) $id = $this->idHandler->getIdentifier($class, $object); if (! $id) { - throw new \RuntimeException('Trying to persist entity that has no id.'); + throw new Exception\RuntimeException('Trying to persist entity that has no id.'); } $idHash = $this->idHandler->hash($id); if (isset($this->identityMap[$class->name][$idHash])) { - throw new \RuntimeException('Object with ID already exists.'); + throw new Exception\RuntimeException('Object with ID already exists.'); } $this->scheduledInsertions[$oid] = $object; @@ -201,7 +201,7 @@ public function scheduleForDelete($object) { $oid = spl_object_hash($object); if (! isset($this->identifiers[$oid])) { - throw new \RuntimeException( + throw new Exception\RuntimeException( 'Object scheduled for deletion is not managed. Only managed objects can be deleted.' ); } @@ -243,7 +243,7 @@ private function processInsertions() $id = $this->idConverter->serialize($class, $id); if (! $id) { - throw new \RuntimeException('Trying to persist entity that has no id.'); + throw new Exception\RuntimeException('Trying to persist entity that has no id.'); } $data = $this->getObjectSnapshot($class, $object); diff --git a/tests/Doctrine/Tests/KeyValueStore/ConfigurationTest.php b/tests/Doctrine/Tests/KeyValueStore/ConfigurationTest.php index 4099354..041c5ef 100644 --- a/tests/Doctrine/Tests/KeyValueStore/ConfigurationTest.php +++ b/tests/Doctrine/Tests/KeyValueStore/ConfigurationTest.php @@ -21,6 +21,7 @@ namespace Doctrine\Tests\KeyValueStore; use Doctrine\KeyValueStore\Configuration; +use Doctrine\KeyValueStore\Exception\Exception; class ConfigurationTest extends \PHPUnit_Framework_TestCase { @@ -28,7 +29,10 @@ public function testNoMappingDriver() { $config = new Configuration(); - $this->setExpectedException('Doctrine\KeyValueStore\KeyValueStoreException', 'No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()'); + $this->setExpectedException( + Exception::class, + 'No mapping driver was assigned to the configuration. Use $config->setMappingDriverImpl()' + ); $config->getMappingDriverImpl(); } diff --git a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/AzureSdkTableTest.php b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/AzureSdkTableTest.php index f143acc..de48fa4 100644 --- a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/AzureSdkTableTest.php +++ b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/AzureSdkTableTest.php @@ -68,7 +68,7 @@ public function testCrud() $storage->delete('test', $key); - $this->setExpectedException("Doctrine\KeyValueStore\NotFoundException"); + $this->setExpectedException("Doctrine\KeyValueStore\Exception\NotFoundException"); $storage->find('test', $key); } diff --git a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/CassandraTest.php b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/CassandraTest.php index cee92dc..2935958 100644 --- a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/CassandraTest.php +++ b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/CassandraTest.php @@ -110,7 +110,7 @@ public function testDelete() $this->storage->insert('books', ['id' => 4], $data); $this->storage->delete('books', ['id' => 4]); - $this->setExpectedException('Doctrine\KeyValueStore\NotFoundException'); + $this->setExpectedException('Doctrine\KeyValueStore\Exception\NotFoundException'); $this->storage->find('books', ['id' => 4]); } diff --git a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/WindowsAzureTableTest.php b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/WindowsAzureTableTest.php index 2af1552..39cf998 100644 --- a/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/WindowsAzureTableTest.php +++ b/tests/Doctrine/Tests/KeyValueStore/Functional/Storage/WindowsAzureTableTest.php @@ -75,7 +75,7 @@ public function testCrud() $storage->delete('test', $key); - $this->setExpectedException("Doctrine\KeyValueStore\NotFoundException"); + $this->setExpectedException("Doctrine\KeyValueStore\Exception\NotFoundException"); $storage->find('test', $key); } diff --git a/tests/Doctrine/Tests/KeyValueStore/Storage/RiakStorageTest.php b/tests/Doctrine/Tests/KeyValueStore/Storage/RiakStorageTest.php index dda3097..579ff6e 100644 --- a/tests/Doctrine/Tests/KeyValueStore/Storage/RiakStorageTest.php +++ b/tests/Doctrine/Tests/KeyValueStore/Storage/RiakStorageTest.php @@ -210,7 +210,7 @@ public function testFind() } /** - * @expectedException Doctrine\KeyValueStore\NotFoundException + * @expectedException Doctrine\KeyValueStore\Exception\NotFoundException */ public function testFindWithNotExistKey() {