Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@
# @link https://github.com/JBZoo/SimpleTypes
#

/.phan export-ignore
/build export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/demo.php export-ignore
/phpunit.xml.dist export-ignore
/Makefile export-ignore

* text eol=lf
2 changes: 2 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

$default = include __DIR__ . '/../vendor/jbzoo/codestyle/src/phan/default.php';

return array_merge($default, [
Expand Down
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0
- nightly

jobs:
fast_finish: true
allow_failures:
- php: 8.0
- php: nightly

env:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JBZoo / SimpleTypes

[![Build Status](https://travis-ci.org/JBZoo/SimpleTypes.svg)](https://travis-ci.org/JBZoo/SimpleTypes) [![Coverage Status](https://coveralls.io/repos/JBZoo/SimpleTypes/badge.svg)](https://coveralls.io/github/JBZoo/SimpleTypes) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes)
[![Build Status](https://travis-ci.org/JBZoo/SimpleTypes.svg)](https://travis-ci.org/JBZoo/SimpleTypes) [![Coverage Status](https://coveralls.io/repos/JBZoo/SimpleTypes/badge.svg)](https://coveralls.io/github/JBZoo/SimpleTypes) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/SimpleTypes/coverage.svg)](https://shepherd.dev/github/JBZoo/SimpleTypes) [![PHP Strict Types](https://img.shields.io/badge/strict__types-%3D1-brightgreen)](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
[![Stable Version](https://poser.pugx.org/jbzoo/simpletypes/version)](https://packagist.org/packages/jbzoo/simpletypes) [![Latest Unstable Version](https://poser.pugx.org/jbzoo/simpletypes/v/unstable)](https://packagist.org/packages/jbzoo/simpletypes) [![Dependents](https://poser.pugx.org/jbzoo/simpletypes/dependents)](https://packagist.org/packages/jbzoo/simpletypes/dependents?order_by=downloads) [![GitHub Issues](https://img.shields.io/github/issues/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/issues) [![Total Downloads](https://poser.pugx.org/jbzoo/simpletypes/downloads)](https://packagist.org/packages/jbzoo/simpletypes/stats) [![GitHub License](https://img.shields.io/github/license/jbzoo/simpletypes)](https://github.com/JBZoo/SimpleTypes/blob/master/LICENSE)


Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
},

"require-dev" : {
"jbzoo/toolbox-dev" : "^2.6.2",
"jbzoo/utils" : "^4.2.3"
"jbzoo/toolbox-dev" : "^2.10.0",
"jbzoo/utils" : "^4.3.0"
},

"autoload" : {
Expand Down
2 changes: 2 additions & 0 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

use JBZoo\SimpleTypes\Config\Config;
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

use JBZoo\SimpleTypes\Formatter;
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Degree.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Config/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

use JBZoo\SimpleTypes\Formatter;
Expand Down Expand Up @@ -81,8 +83,7 @@ public function getRules(): array

'bit' => [
'symbol' => 'Bit',
'rate' => static function (int $value, string $ruleTo) {

'rate' => static function (float $value, string $ruleTo) {
if ($ruleTo === 'bit') {
return $value * 8;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

use JBZoo\SimpleTypes\Formatter;
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Temp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Config/Weight.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Config;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes;

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes;

/**
Expand Down Expand Up @@ -253,9 +255,9 @@ protected function format(float $value, string $rule): array
$isPositive = ($value >= 0);
$valueStr = number_format(
abs($roundedValue),
$format['num_decimals'],
$format['decimal_sep'],
$format['thousands_sep']
(int)($format['num_decimals'] ?? 0),
(string)($format['decimal_sep'] ?? '.'),
(string)($format['thousands_sep'] ?? '')
);

$template = $isPositive ? $format['format_positive'] : $format['format_negative'];
Expand Down
2 changes: 2 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

use JBZoo\SimpleTypes\Config\Config;
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Degree.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Temp.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Volume.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Type/Weight.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @link https://github.com/JBZoo/SimpleTypes
*/

declare(strict_types=1);

namespace JBZoo\SimpleTypes\Type;

/**
Expand Down
Loading