Skip to content

Commit

Permalink
Merge pull request #33 from zfbrasil/hotfix/dependencies
Browse files Browse the repository at this point in the history
Update dependency constraints
  • Loading branch information
danizord authored Jun 20, 2016
2 parents e6d7293 + df26ab0 commit 954f04f
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ before_script:
script:
- composer install --prefer-source
- vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
- vendor/bin/php-cs-fixer fix -v --dry-run ./test
- vendor/bin/php-cs-fixer fix -v --fixers=-empty_return --diff --dry-run ./src
- vendor/bin/php-cs-fixer fix -v --fixers=-empty_return --diff --dry-run ./test

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
Expand Down
33 changes: 17 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@
}
],
"require-dev": {
"phpunit/phpunit": "~4.4",
"fabpot/php-cs-fixer": "dev-master",
"doctrine/dbal": "~2.5",
"doctrine/mongodb-odm": "1.0.*@dev"
"phpunit/phpunit": "^4.4",
"friendsofphp/php-cs-fixer": "^1.11",
"doctrine/dbal": "^2.5",
"doctrine/mongodb-odm": "^1.0"
},
"require": {
"php": ">=5.5",
"doctrine/doctrine-module": "~0.8 || ~1.0",
"zendframework/zend-form": "~2.3",
"zendframework/zend-filter": "~2.3",
"zendframework/zend-validator": "~2.3",
"zendframework/zend-view": "~2.3",
"zendframework/zend-servicemanager": "~2.3",
"zendframework/zend-modulemanager": "~2.3",
"zendframework/zend-i18n": "~2.3",
"mathiasverraes/money": "1.2.*"
"php": "^5.5 || ^7.0",
"doctrine/doctrine-module": "^0.8 || ^1.0",
"zendframework/zend-form": "^2.3",
"zendframework/zend-filter": "^2.3",
"zendframework/zend-validator": "^2.3",
"zendframework/zend-view": "^2.3",
"zendframework/zend-servicemanager": "^2.3",
"zendframework/zend-modulemanager": "^2.3",
"zendframework/zend-i18n": "^2.3",
"mathiasverraes/money": "^1.2"
},
"suggest": {
"doctrine/dbal": "2.5.*",
"doctrine/mongodb-odm": "1.0.*@dev"
"doctrine/dbal": "^2.5",
"doctrine/mongodb-odm": "^1.0",
"doctrine/orm": "^2.5"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 3 additions & 4 deletions src/DBAL/Types/CurrencyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Doctrine\DBAL\Types\StringType;
use Money\Currency;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Platforms\AbstractPlatform;

/**
Expand All @@ -14,17 +13,17 @@
class CurrencyType extends StringType
{
const NAME = 'currency';

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getName()
{
return self::NAME;
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Filter/AmountFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Money\InvalidArgumentException;
use Money\Money;
use Zend\Filter\AbstractFilter;
use Zend\Filter\Exception;

/**
* @author Gabriel Schmitt <[email protected]>
Expand All @@ -14,10 +13,11 @@
class AmountFilter extends AbstractFilter
{
/**
* {@inheritDoc}
* {@inheritdoc}
*
* @throws InvalidArgumentException
* @return int
*
* @return int|null
*/
public function filter($value)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Form/Element/Factory/CurrencySelectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class CurrencySelectFactory
{
/**
* @param FormElementManager $formElementManager
*
* @return CurrencySelect
*/
public function __invoke(FormElementManager $formElementManager)
{
$serviceManager = $formElementManager->getServiceLocator();
$config = $serviceManager->get('Config');

if (! isset($config['money']['currencies'])) {
if (!isset($config['money']['currencies'])) {
throw new InvalidArgumentException('Couldn\'t find currencies configuration.');
}

Expand Down
14 changes: 7 additions & 7 deletions src/Form/MoneyFieldset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@
use ZFBrasil\DoctrineMoneyModule\InputFilter\MoneyInputFilter;

/**
* Money form element that will make it very easy to work with money and currencies
* Money form element that will make it very easy to work with money and currencies.
*
* @author Fábio Carneiro <[email protected]>
* @license MIT
*/
class MoneyFieldset extends Fieldset implements InputFilterProviderInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function init()
{
$this->add([
'type' => Number::class,
'name' => 'amount',
'options' => [
'label' => 'Amount'
'label' => 'Amount',
],
'attributes' => [
'step' => '0.01',
]
],
]);

$this->add([
'type' => CurrencySelect::class,
'name' => 'currency',
'options' => [
'label' => 'Currency'
]
'label' => 'Currency',
],
]);
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getInputFilterSpecification()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Hydrator/MoneyHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@
use Money\Currency;

/**
* Hydrator for Money object
* Hydrator for Money object.
*
* @author Fábio Carneiro <[email protected]>
* @license MIT
*/
class MoneyHydrator implements HydratorInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function extract($object)
{
return [
'amount' => $object->getAmount(),
'currency' => $object->getCurrency()->getName()
'currency' => $object->getCurrency()->getName(),
];
}

/**
* {@inheritDoc}
* {@inheritdoc}
*
* @return Money
* @return Money|null
*/
public function hydrate(array $data, $object)
{
Expand Down
14 changes: 7 additions & 7 deletions src/InputFilter/MoneyInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
class MoneyInputFilter extends InputFilter
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function init()
{
$this->add([
'name' => 'amount',
'required' => true,
'filters' => [
['name' => AmountFilter::class]
['name' => AmountFilter::class],
],
'validators' => [
['name' => NotEmpty::class]
]
['name' => NotEmpty::class],
],
]);

$this->add([
'name' => 'currency',
'required' => true,
'filters' => [
['name' => StringToUpper::class]
['name' => StringToUpper::class],
],
'validators' => [
['name' => NotEmpty::class]
]
['name' => NotEmpty::class],
],
]);
}
}
4 changes: 2 additions & 2 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
class Module implements ConfigProviderInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getConfig()
{
return require __DIR__ . '/../config/module.config.php';
return require __DIR__.'/../config/module.config.php';
}
}
13 changes: 13 additions & 0 deletions src/ODM/MongoDB/Types/CurrencyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ class CurrencyType extends Type
{
const NAME = 'currency';

/**
* @return string
*/
public function getName()
{
return self::NAME;
}

/**
* @param mixed $value
*
* @return null|string
*/
public function convertToDatabaseValue($value)
{
if ($value) {
Expand All @@ -23,6 +31,11 @@ public function convertToDatabaseValue($value)
return null;
}

/**
* @param string $value
*
* @return string|Currency
*/
public function convertToPHPValue($value)
{
if ($value === null || $value instanceof Currency) {
Expand Down
11 changes: 6 additions & 5 deletions src/View/Helper/MoneyFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
class MoneyFormat extends AbstractHelper
{
/**
* @param Money $money
* @param bool $showDecimals
* @param string $locale
* @param string $pattern
* @param Money $money
* @param bool $showDecimals
* @param string $locale
* @param string $pattern
*
* @return string
*/
public function __invoke(Money $money, $showDecimals = null, $locale = null, $pattern = null)
{
$currencyFormat = $this->getView()->plugin('currencyFormat');

return $currencyFormat($money->getAmount() / 100, $money->getCurrency(), $showDecimals, $locale, $pattern);
}
}
6 changes: 3 additions & 3 deletions test/Form/Element/Factory/CurrencySelectFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class CurrencySelectFactoryTest extends TestCase
'money' => [
'currencies' => [
'BRL' => 'Brazilian Real',
'SAD' => 'Sad Asteka'
]
]
'SAD' => 'Sad Asteka',
],
],
];

public function setUp()
Expand Down
Loading

0 comments on commit 954f04f

Please sign in to comment.