Replace BadMethodCallException with UnsatisfiedDependencyException

This commit is contained in:
Ben Ramsey
2013-01-19 12:48:05 -06:00
parent ad3bde8b24
commit 8f63d671a7
3 changed files with 44 additions and 24 deletions
@@ -0,0 +1,20 @@
<?php
/**
* This file is part of the Rhumsaa\Uuid library
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Copyright (c) 2012 Ben Ramsey <http://benramsey.com>
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Rhumsaa\Uuid\Exception;
/**
* Thrown to indicate that the requested operation has depencies that have not
* been satisfied.
*/
class UnsatisfiedDependencyException extends \RuntimeException
{
}
+16 -16
View File
@@ -297,7 +297,7 @@ class Uuid
*
* @return \DateTime
* @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID
* @throws \BadMethodCallException if called on a 32-bit system and Moontoast\Math\BigNumber is not present
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and Moontoast\Math\BigNumber is not present
*/
public function getDateTime()
{
@@ -323,7 +323,7 @@ class Uuid
} else {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'When calling ' . __METHOD__ . ' on a 32-bit system, '
. 'Moontoast\Math\BigNumber must be present in order '
. 'to extract DateTime from version 1 UUIDs'
@@ -339,12 +339,12 @@ class Uuid
* to the RFC 4122 names for the fields.
*
* @return array
* @throws \BadMethodCallException if called on a 32-bit system
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
*/
public function getFields()
{
if (!self::is64BitSystem()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' on a 32-bit system, since some '
. 'values overflow the system max integer value'
);
@@ -375,12 +375,12 @@ class Uuid
* Returns the least significant 64 bits of this UUID's 128 bit value
*
* @return \Moontoast\Math\BigNumber
* @throws \BadMethodCallException if Moontoast\Math\BigNumber is not present
* @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
*/
public function getLeastSignificantBits()
{
if (!self::hasBigNumber()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' without support for large '
. 'integers, since least significant bits is an unsigned '
. '64-bit integer; Moontoast\Math\BigNumber is required'
@@ -415,12 +415,12 @@ class Uuid
* Returns the most significant 64 bits of this UUID's 128 bit value
*
* @return \Moontoast\Math\BigNumber
* @throws \BadMethodCallException if Moontoast\Math\BigNumber is not present
* @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
*/
public function getMostSignificantBits()
{
if (!self::hasBigNumber()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' without support for large '
. 'integers, since most significant bits is an unsigned '
. '64-bit integer; Moontoast\Math\BigNumber is required'
@@ -474,12 +474,12 @@ class Uuid
*
* @return int
* @see http://tools.ietf.org/html/rfc4122#section-4.1.6
* @throws \BadMethodCallException if called on a 32-bit system
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
*/
public function getNode()
{
if (!self::is64BitSystem()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' on a 32-bit system, since node '
. 'is an unsigned 48-bit integer and can overflow the system '
. 'max integer value'
@@ -525,12 +525,12 @@ class Uuid
* Returns the low field of the timestamp (the first 32 bits of the UUID).
*
* @return int
* @throws \BadMethodCallException if called on a 32-bit system
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
*/
public function getTimeLow()
{
if (!self::is64BitSystem()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' on a 32-bit system, since time_low '
. 'is an unsigned 32-bit integer and can overflow the system '
. 'max integer value'
@@ -584,7 +584,7 @@ class Uuid
*
* @return int
* @throws Exception\UnsupportedOperationException If this UUID is not a version 1 UUID
* @throws \BadMethodCallException if called on a 32-bit system
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system
* @see http://tools.ietf.org/html/rfc4122#section-4.1.4
*/
public function getTimestamp()
@@ -594,7 +594,7 @@ class Uuid
}
if (!self::is64BitSystem()) {
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'Cannot call ' . __METHOD__ . ' on a 32-bit system, since timestamp '
. 'is an unsigned 60-bit integer and can overflow the system '
. 'max integer value'
@@ -858,7 +858,7 @@ class Uuid
* since 00:00:00.00, 15 October 1582.
*
* @return array
* @throws \BadMethodCallException if called on a 32-bit system and Moontoast\Math\BigNumber is not present
* @throws Exception\UnsatisfiedDependencyException if called on a 32-bit system and Moontoast\Math\BigNumber is not present
*/
protected static function calculateUuidTime($sec, $usec)
{
@@ -896,7 +896,7 @@ class Uuid
);
}
throw new \BadMethodCallException(
throw new Exception\UnsatisfiedDependencyException(
'When calling ' . __METHOD__ . ' on a 32-bit system, '
. 'Moontoast\Math\BigNumber must be present in order '
. 'to generate version 1 UUIDs'
+8 -8
View File
@@ -186,7 +186,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getDateTime
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetDateTimeThrownException()
{
@@ -233,7 +233,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getFields
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetFields32Bit()
{
@@ -273,7 +273,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getLeastSignificantBits
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetLeastSignificantBitsException()
{
@@ -303,7 +303,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getMostSignificantBits
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetMostSignificantBitsException()
{
@@ -334,7 +334,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getNode
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetNode32Bit()
{
@@ -383,7 +383,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getTimeLow
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetTimeLow32Bit()
{
@@ -464,7 +464,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::getTimestamp
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testGetTimestamp32Bit()
{
@@ -1164,7 +1164,7 @@ class UuidTest extends \PHPUnit_Framework_TestCase
/**
* @covers Rhumsaa\Uuid\Uuid::calculateUuidTime
* @expectedException BadMethodCallException
* @expectedException Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException
*/
public function testCalculateUuidTimeThrownException()
{