Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
package
money
Commits
aa241d0a
Commit
aa241d0a
authored
Oct 28, 2011
by
Mathias Verraes
Browse files
shorter namespace
parent
ef68dd58
Changes
12
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
aa241d0a
.project
.buildpath
.settings
build/
\ No newline at end of file
build/
phpunit.xml
\ No newline at end of file
README.md
View file @
aa241d0a
Verraes\
Money
Money
=============
Also see http://blog.verraes.net/2011/04/fowler-money-pattern-in-php/
...
...
lib/
Verraes/
Money/Currency.php
→
lib/Money/Currency.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
class
Currency
{
...
...
lib/
Verraes/
Money/CurrencyPair.php
→
lib/Money/CurrencyPair.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
/** @see http://en.wikipedia.org/wiki/Currency_pair */
class
CurrencyPair
...
...
lib/
Verraes/
Money/Exception.php
→
lib/Money/Exception.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
/**
* @see http://www.phpkode.com/tips/item/exception-best-practices-in-php-5-3/
...
...
lib/
Verraes/
Money/InvalidArgumentException.php
→
lib/Money/InvalidArgumentException.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
class
InvalidArgumentException
extends
\
InvalidArgumentException
implements
Exception
{
...
...
lib/
Verraes/
Money/Money.php
→
lib/Money/Money.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
class
Money
{
...
...
@@ -22,14 +22,14 @@ class Money
*/
private
$units
;
/** @var
Verraes\
Money\Currency */
/** @var Money\Currency */
private
$currency
;
/**
* Create a Money instance
* @param integer $units Amount, expressed in the smallest units of $currency (eg cents)
* @param
Verraes\
Money\Currency $currency
* @throws
Verraes\
Money\InvalidArgumentException
* @param Money\Currency $currency
* @throws Money\InvalidArgumentException
*/
public
function
__construct
(
$units
,
Currency
$currency
)
{
...
...
@@ -83,7 +83,7 @@ class Money
}
/**
* @throws
Verraes\
Money\InvalidArgumentException
* @throws Money\InvalidArgumentException
*/
private
function
assertSameCurrency
(
Money
$other
)
{
...
...
@@ -130,7 +130,7 @@ class Money
}
/**
* @return
Verraes\
Money\Currency
* @return Money\Currency
*/
public
function
getCurrency
()
{
...
...
@@ -150,7 +150,7 @@ class Money
}
/**
* @throws
Verraes\
Money\InvalidArgumentException
* @throws Money\InvalidArgumentException
*/
private
function
assertOperand
(
$operand
)
{
...
...
@@ -160,7 +160,7 @@ class Money
}
/**
* @throws
Verraes\
Money\InvalidArgumentException
* @throws Money\InvalidArgumentException
*/
private
function
assertRoundingMode
(
$rounding_mode
)
{
...
...
lib/
Verraes/
Money/UnknownCurrencyException.php
→
lib/Money/UnknownCurrencyException.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -8,7 +8,7 @@
* file that was distributed with this source code.
*/
namespace
Verraes\
Money
;
namespace
Money
;
class
UnknownCurrencyException
extends
\
Exception
implements
Exception
{
...
...
tests/CurrencyPairTest.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -10,9 +10,9 @@
require_once
'bootstrap.php'
;
use
Verraes\
Money\Money
;
use
Verraes\
Money\Currency
;
use
Verraes\
Money\CurrencyPair
;
use
Money\Money
;
use
Money\Currency
;
use
Money\CurrencyPair
;
class
CurrencyPairTest
extends
PHPUnit_Framework_TestCase
{
...
...
tests/CurrencyTest.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -10,7 +10,7 @@
require_once
'bootstrap.php'
;
use
Verraes\
Money\Currency
;
use
Money\Currency
;
class
CurrencyTest
extends
PHPUnit_Framework_TestCase
{
...
...
@@ -41,7 +41,7 @@ class CurrencyTest extends PHPUnit_Framework_TestCase
/**
* @test
* @expectedException
Verraes\
Money\UnknownCurrencyException
* @expectedException Money\UnknownCurrencyException
*/
public
function
testCantInstantiateUnknownCurrency
()
{
...
...
tests/MoneyTest.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -10,8 +10,8 @@
require_once
'bootstrap.php'
;
use
Verraes\
Money\Money
;
use
Verraes\
Money\Currency
;
use
Money\Money
;
use
Money\Currency
;
class
MoneyTest
extends
PHPUnit_Framework_TestCase
{
...
...
@@ -50,7 +50,7 @@ class MoneyTest extends PHPUnit_Framework_TestCase
}
/**
* @expectedException
Verraes\
Money\InvalidArgumentException
* @expectedException Money\InvalidArgumentException
*/
public
function
testDecimalsThrowException
()
{
...
...
@@ -58,7 +58,7 @@ class MoneyTest extends PHPUnit_Framework_TestCase
}
/**
* @expectedException
Verraes\
Money\InvalidArgumentException
* @expectedException Money\InvalidArgumentException
*/
public
function
testStringThrowsException
()
{
...
...
@@ -92,7 +92,7 @@ class MoneyTest extends PHPUnit_Framework_TestCase
}
/**
* @expectedException
Verraes\
Money\InvalidArgumentException
* @expectedException Money\InvalidArgumentException
*/
public
function
testDifferentCurrenciesCannotBeAdded
()
{
...
...
@@ -116,7 +116,7 @@ class MoneyTest extends PHPUnit_Framework_TestCase
}
/**
* @expectedException
Verraes\
Money\InvalidArgumentException
* @expectedException Money\InvalidArgumentException
*/
public
function
testDifferentCurrenciesCannotBeSubtracted
()
{
...
...
@@ -176,7 +176,7 @@ class MoneyTest extends PHPUnit_Framework_TestCase
}
/**
* @expectedException
Verraes\
Money\InvalidArgumentException
* @expectedException Money\InvalidArgumentException
*/
public
function
testDifferentCurrenciesCannotBeCompared
()
{
...
...
tests/bootstrap.php
View file @
aa241d0a
<?php
/**
* This file is part of the
Verraes\
Money library
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
*
...
...
@@ -9,9 +9,9 @@
*/
require_once
'PHPUnit/Framework/TestCase.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/Currency.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/CurrencyPair.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/Exception.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/InvalidArgumentException.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/UnknownCurrencyException.php'
;
require_once
__DIR__
.
'/../lib/
Verraes/
Money/Money.php'
;
require_once
__DIR__
.
'/../lib/Money/Currency.php'
;
require_once
__DIR__
.
'/../lib/Money/CurrencyPair.php'
;
require_once
__DIR__
.
'/../lib/Money/Exception.php'
;
require_once
__DIR__
.
'/../lib/Money/InvalidArgumentException.php'
;
require_once
__DIR__
.
'/../lib/Money/UnknownCurrencyException.php'
;
require_once
__DIR__
.
'/../lib/Money/Money.php'
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment