-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
7,678 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/bin/ | ||
/composer.lock | ||
/phpunit.xml | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
php_code_sniffer: true | ||
php_cpd: true | ||
php_loc: true | ||
php_mess_detector: true | ||
php_pdepend: true | ||
php_analyzer: true | ||
sensiolabs_security_checker: true | ||
filter: | ||
paths: [src/*] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
- nightly | ||
|
||
before_script: | ||
- composer self-update | ||
- composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- bin/phpunit --coverage-clover=coverage.clover --coverage-text | ||
|
||
after_script: | ||
- wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Contributing | ||
============ | ||
|
||
If you are reading this, **thank you**! You are about to make things better and this makes you **a hero**! | ||
|
||
Here are a few rules to follow in order to ease code reviews, and discussions before | ||
maintainers accept and merge your work. | ||
|
||
You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and | ||
[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you | ||
should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer | ||
tool](http://cs.sensiolabs.org/). | ||
|
||
You MUST run the test suite. | ||
|
||
You MUST write (or update) unit tests. | ||
|
||
You SHOULD write documentation. | ||
|
||
Please, write [commit messages that make | ||
sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), | ||
and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) | ||
before submitting your Pull Request. | ||
|
||
One may ask you to [squash your | ||
commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) | ||
too. This is used to "clean" your Pull Request before merging it (we don't want | ||
commits such as `fix tests`, `fix 2`, `fix 3`, etc.). | ||
|
||
Thank you very much! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Nicolò Pignatelli | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
# valueobjects | ||
ValueObjects | ||
============ | ||
|
||
*nicolopignatelli/valueobjects* | ||
|
||
Temporary substitute library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
UPGRADE FROM 2.x to 3.0 | ||
======================= | ||
|
||
### StringLiteral | ||
|
||
* The `String` and `Null` classed and namespaces have been respectively renamed to | ||
`StringLiteral` and `NullValue` in order to be compatible with PHP 7. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "ytake/valueobjects", | ||
"description": "A PHP library/collection of classes aimed to help developers using and undestanding immutable objects.(temporary package)", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Nicolò Pignatelli", | ||
"email": "pignatelli.nicolo@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4", | ||
"ramsey/uuid": "~3.0", | ||
"mathiasverraes/money": "~1.2", | ||
"marc-mabe/php-enum": "~1.0", | ||
"zendframework/zend-validator": "~2.2", | ||
"league/geotools": "~0.7" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.0" | ||
}, | ||
"config": { | ||
"bin-dir": "bin" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"ValueObjects\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"ValueObjects\\Tests\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "4.2.x-dev" | ||
} | ||
}, | ||
"replace": { | ||
"nicolopignatelli/valueobjects": "^4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuites> | ||
<testsuite name="valueobjects Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory>./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ValueObjects\Climate; | ||
|
||
class Celsius extends Temperature | ||
{ | ||
/** | ||
* @return Celsius | ||
*/ | ||
public function toCelsius() | ||
{ | ||
return new static($this->value); | ||
} | ||
|
||
/** | ||
* @return Kelvin | ||
*/ | ||
public function toKelvin() | ||
{ | ||
return new Kelvin($this->value + 273.15); | ||
} | ||
|
||
/** | ||
* @return Fahrenheit | ||
*/ | ||
public function toFahrenheit() | ||
{ | ||
return new Fahrenheit($this->value * 1.8 + 32); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ValueObjects\Climate; | ||
|
||
class Fahrenheit extends Temperature | ||
{ | ||
/** | ||
* @return Celsius | ||
*/ | ||
public function toCelsius() | ||
{ | ||
return new Celsius(($this->value - 32) / 1.8); | ||
} | ||
|
||
/** | ||
* @return Kelvin | ||
*/ | ||
public function toKelvin() | ||
{ | ||
return new Kelvin($this->toCelsius()->toNative() + 273.15); | ||
} | ||
|
||
/** | ||
* @return Fahrenheit | ||
*/ | ||
public function toFahrenheit() | ||
{ | ||
return new static($this->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ValueObjects\Climate; | ||
|
||
class Kelvin extends Temperature | ||
{ | ||
/** | ||
* @return Celsius | ||
*/ | ||
public function toCelsius() | ||
{ | ||
return new Celsius($this->value - 273.15); | ||
} | ||
|
||
/** | ||
* @return Kelvin | ||
*/ | ||
public function toKelvin() | ||
{ | ||
return new static($this->value); | ||
} | ||
|
||
/** | ||
* @return Fahrenheit | ||
*/ | ||
public function toFahrenheit() | ||
{ | ||
return new Fahrenheit($this->toCelsius()->toNative() * 1.8 + 32); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace ValueObjects\Climate; | ||
|
||
use ValueObjects\Number\Natural; | ||
use ValueObjects\Exception\InvalidNativeArgumentException; | ||
|
||
class RelativeHumidity extends Natural | ||
{ | ||
const MIN = 0; | ||
|
||
const MAX = 100; | ||
|
||
/** | ||
* Returns a new RelativeHumidity from native int value | ||
* | ||
* @param int $value | ||
* @return RelativeHumidity | ||
*/ | ||
public static function fromNative() | ||
{ | ||
$value = func_get_arg(0); | ||
|
||
return new static($value); | ||
} | ||
|
||
/** | ||
* Returns a new RelativeHumidity object | ||
* | ||
* @param int $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$options = array( | ||
'options' => array('min_range' => self::MIN, 'max_range' => self::MAX) | ||
); | ||
|
||
$value = filter_var($value, FILTER_VALIDATE_INT, $options); | ||
|
||
if (false === $value) { | ||
throw new InvalidNativeArgumentException($value, array('int (>=' . self::MIN . ', <=' . self::MAX . ')')); | ||
} | ||
|
||
parent::__construct($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace ValueObjects\Climate; | ||
|
||
use ValueObjects\Number\Real; | ||
|
||
abstract class Temperature extends Real | ||
{ | ||
/** | ||
* @return Celsius | ||
*/ | ||
abstract public function toCelsius(); | ||
|
||
/** | ||
* @return Kelvin | ||
*/ | ||
abstract public function toKelvin(); | ||
|
||
/** | ||
* @return Fahrenheit | ||
*/ | ||
abstract public function toFahrenheit(); | ||
} |
Oops, something went wrong.