Skip to content

Commit

Permalink
fixes for php7
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Dec 7, 2015
1 parent 7ed859c commit 0d18015
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class FieldFactory implements FieldFactoryInterface
protected $cachedTypes = [];
protected $namespaces = ['SimpleCrud\\Fields\\'];
protected $defaultType = 'SimpleCrud\\Fields\\Field';
protected $smartTypes = [
'Decimal' => ['float'],
];
protected $smartNames = [
'Boolean' => ['active'],
'Datetime' => ['pubdate'],
Expand Down Expand Up @@ -122,9 +125,16 @@ protected function getTypeByName($name)
*
* @return string|null
*/
protected function getClass($name)
protected function getClass($type)
{
$name = ucfirst($name);
foreach ($this->smartTypes as $smartType => $types) {
if (in_array($type, $types, true)) {
$type = $smartType;
break;
}
}

$name = ucfirst($type);

foreach ($this->namespaces as $namespace) {
$class = $namespace.$name;
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Float.php → src/Fields/Decimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* To normalize float values.
*/
class Float extends Integer
class Decimal extends Integer
{
/**
* Normalize a float.
Expand Down

0 comments on commit 0d18015

Please sign in to comment.