Commit cb1150bf authored by Mathias Verraes's avatar Mathias Verraes
Browse files

Docblocks cleanup

parent a7efa509
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......@@ -15,8 +15,13 @@ class Currency
/** @var string */
private $name;
/** @var array */
private static $currencies;
/**
* @param string $name
* @throws UnknownCurrencyException
*/
public function __construct($name)
{
if(!isset(static::$currencies)) {
......@@ -39,6 +44,7 @@ class Currency
}
/**
* @param \Money\Currency $other
* @return bool
*/
public function equals(Currency $other)
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......@@ -22,6 +22,12 @@ class CurrencyPair
/** @var float */
private $ratio;
/**
* @param \Money\Currency $counterCurrency
* @param \Money\Currency $baseCurrency
* @param float $ratio
* @throws \Money\InvalidArgumentException
*/
public function __construct(Currency $counterCurrency, Currency $baseCurrency, $ratio)
{
if(!is_numeric($ratio)) {
......@@ -34,8 +40,9 @@ class CurrencyPair
}
/**
* @param string $iso String representation of the form "EUR/USD 1.2500"
* @return CurrencyPair
* @param string $iso String representation of the form "EUR/USD 1.2500"
* @throws \Exception
* @return \Money\CurrencyPair
*/
public static function createFromIso($iso)
{
......@@ -52,7 +59,11 @@ class CurrencyPair
return new static(new Currency($matches[1]), new Currency($matches[2]), $matches[3]);
}
/** @return Money */
/**
* @param \Money\Money $money
* @throws InvalidArgumentException
* @return \Money\Money
*/
public function convert(Money $money)
{
if (!$money->getCurrency()->equals($this->counterCurrency)) {
......@@ -63,13 +74,13 @@ class CurrencyPair
return new Money((int) round($money->getAmount() * $this->ratio), $this->baseCurrency);
}
/** @return Currency */
/** @return \Money\Currency */
public function getCounterCurrency()
{
return $this->counterCurrency;
}
/** @return Currency */
/** @return \Money\Currency */
public function getBaseCurrency()
{
return $this->baseCurrency;
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......@@ -22,14 +22,14 @@ class Money
*/
private $amount;
/** @var Money\Currency */
/** @var \Money\Currency */
private $currency;
/**
* Create a Money instance
* @param integer $amount Amount, expressed in the smallest units of $currency (eg cents)
* @param Money\Currency $currency
* @throws Money\InvalidArgumentException
* @param integer $amount Amount, expressed in the smallest units of $currency (eg cents)
* @param \Money\Currency $currency
* @throws \Money\InvalidArgumentException
*/
public function __construct($amount, Currency $currency)
{
......@@ -43,21 +43,26 @@ class Money
/**
* Convenience factory method for a Money object
* @example $fiveDollar = Money::USD(500);
* @return Money
* @param string $method
* @param array $arguments
* @return \Money\Money
*/
public static function __callStatic($method, $arguments)
{
return new Money($arguments[0], new Currency($method));
}
/** @return bool */
/**
* @param \Money\Money $other
* @return bool
*/
public function isSameCurrency(Money $other)
{
return $this->currency->equals($other->currency);
}
/**
* @throws Money\InvalidArgumentException
* @throws \Money\InvalidArgumentException
*/
private function assertSameCurrency(Money $other)
{
......@@ -66,6 +71,10 @@ class Money
}
}
/**
* @param \Money\Money $other
* @return bool
*/
public function equals(Money $other)
{
return
......@@ -73,6 +82,10 @@ class Money
&& $this->amount == $other->amount;
}
/**
* @param \Money\Money $other
* @return int
*/
public function compare(Money $other)
{
$this->assertSameCurrency($other);
......@@ -85,11 +98,19 @@ class Money
}
}
/**
* @param \Money\Money $other
* @return bool
*/
public function greaterThan(Money $other)
{
return 1 == $this->compare($other);
}
/**
* @param \Money\Money $other
* @return bool
*/
public function lessThan(Money $other)
{
return -1 == $this->compare($other);
......@@ -113,13 +134,17 @@ class Money
}
/**
* @return Money\Currency
* @return \Money\Currency
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @param \Money\Money $addend
*@return \Money\Money
*/
public function add(Money $addend)
{
$this->assertSameCurrency($addend);
......@@ -127,6 +152,10 @@ class Money
return new self($this->amount + $addend->amount, $this->currency);
}
/**
* @param \Money\Money $subtrahend
* @return \Money\Money
*/
public function subtract(Money $subtrahend)
{
$this->assertSameCurrency($subtrahend);
......@@ -135,7 +164,7 @@ class Money
}
/**
* @throws Money\InvalidArgumentException
* @throws \Money\InvalidArgumentException
*/
private function assertOperand($operand)
{
......@@ -145,7 +174,7 @@ class Money
}
/**
* @throws Money\InvalidArgumentException
* @throws \Money\InvalidArgumentException
*/
private function assertRoundingMode($rounding_mode)
{
......@@ -154,6 +183,11 @@ class Money
}
}
/**
* @param $multiplier
* @param int $rounding_mode
* @return \Money\Money
*/
public function multiply($multiplier, $rounding_mode = self::ROUND_HALF_UP)
{
$this->assertOperand($multiplier);
......@@ -164,6 +198,11 @@ class Money
return new Money($product, $this->currency);
}
/**
* @param $divisor
* @param int $rounding_mode
* @return \Money\Money
*/
public function divide($divisor, $rounding_mode = self::ROUND_HALF_UP)
{
$this->assertOperand($divisor);
......@@ -177,6 +216,7 @@ class Money
/**
* Allocate the money according to a list of ratio's
* @param array $ratios List of ratio's
* @return \Money\Money
*/
public function allocate(array $ratios)
{
......@@ -215,7 +255,11 @@ class Money
return $this->amount < 0;
}
/** @return int */
/**
* @param $string
* @throws \Money\InvalidArgumentException
* @return int
*/
public static function stringToUnits( $string )
{
//@todo extend the regular expression with grouping characters and eventually currencies
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
......@@ -2,7 +2,7 @@
/**
* This file is part of the Money library
*
* Copyright (c) 2011 Mathias Verraes
* Copyright (c) 2011-2013 Mathias Verraes
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment