Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple improvements, see CHANGELOG #86

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5308d56
Added storage types
lsv Sep 26, 2017
5ece806
coding standard fix
lsv Sep 26, 2017
3a2bf30
Use composer scripts
tomasfejfar Oct 30, 2017
5100de1
Added ly (light year) and pc (parsec) length units.
landy2005 Apr 18, 2019
ca6ad0b
Added power factor for Si prefixes, allowed use prefixes on squire, c…
landy2005 Apr 18, 2019
808ac69
Use Si prefixes for area units
landy2005 Apr 18, 2019
4579f2b
Added energy units electronvolt, calorie
landy2005 Apr 18, 2019
a446090
Added Si prefixes for volume unit cubic meter.
landy2005 Apr 18, 2019
0bd6aed
Added Si prefixes for volume unit liter
landy2005 Apr 18, 2019
cbf73df
Fixed liter Si prefixes
landy2005 Apr 18, 2019
ac53b1a
Added units for mass: Hundredweight, US short Ton, US long Ton, Asian…
landy2005 Apr 18, 2019
bc265c5
Added alias for volume litres
landy2005 Apr 18, 2019
5fe93d3
Additional units for pressure: Torr, Technical atmosphere, Kilo and M…
landy2005 Apr 18, 2019
3eb79a2
Added Si prefixes for velocity units, added new velocity units.
landy2005 Apr 19, 2019
15f238c
Added lowercase aliases for temperature units
landy2005 Apr 19, 2019
c45d530
Added unittests for termperature units
landy2005 Apr 19, 2019
bef50b6
Added alias for knot velocity unit
landy2005 Apr 19, 2019
fdce812
Added Si prefixes for acceleration unit m/s^2
landy2005 Apr 19, 2019
3fde6bb
Additional unit for power: dBm
landy2005 Apr 19, 2019
efa49fb
More accurate volume units factor
landy2005 Apr 19, 2019
88b994c
Added new Physical Quantity volume flow with commonly used units
landy2005 Apr 19, 2019
0c0fd10
Merge pull request #1 from lsv/feature/storage
landy2005 Apr 19, 2019
037ca76
Merge pull request #2 from tomasfejfar/composer-scripts
landy2005 Apr 19, 2019
eef6f7d
Increased minimum php version to 5.6
landy2005 Apr 19, 2019
6361446
Fixed PHP CS tests
landy2005 Apr 20, 2019
fcf010d
Update README.md
landy2005 Feb 17, 2021
8dec0f3
Update .travis.yml
landy2005 Feb 17, 2021
1eb60a0
Update README
landy2005 Feb 17, 2021
f7f2876
Fix Xdebug coverage error.
landy2005 Feb 17, 2021
28ac980
Update phpcs version.
landy2005 Feb 17, 2021
2a80a22
Fix dist for php 8.0
landy2005 Feb 17, 2021
1435e5f
Fix travis job for php 8.0
landy2005 Feb 17, 2021
2df340f
Fix phpcs error
landy2005 Feb 17, 2021
0440ea8
Update dist for nightly php.
landy2005 Feb 17, 2021
ee465a9
Switch to phpunit 6.
landy2005 Feb 17, 2021
b26c2f7
Try different phpunit on php 8.0
landy2005 Feb 17, 2021
1730633
Try different phpunit on php 8.0
landy2005 Feb 17, 2021
bc231e7
Try different phpunit on php 8.0
landy2005 Feb 17, 2021
2daf0be
Try different phpunit on php 8.0 and 5.6
landy2005 Feb 17, 2021
c7b7425
Fix phpunit tests
landy2005 Feb 17, 2021
2053365
Fix phpunit tests
landy2005 Feb 17, 2021
29065ea
Enable phpunit tests for all php versions.
landy2005 Feb 17, 2021
676a643
feat: modernise, drop support for php < 7.4, migrate tests and config…
Chris8934 Feb 4, 2023
2884e02
feat: modernise, drop support for php < 7.4, migrate tests and config…
Chris8934 Feb 4, 2023
30ce239
feat: modernise, drop support for php < 7.4, migrate tests and config…
Chris8934 Feb 4, 2023
95b6562
Merge branch 'master' into master
landy2005 Nov 2, 2023
58e5ccd
Create HasIECUnitsTrait.php
landy2005 Nov 2, 2023
61fcdaa
Merge branch 'feature/modernise' of https://github.com/Chris53897/php…
landy2005 Nov 2, 2023
6b175c4
Fixed UnitTests.
landy2005 Nov 2, 2023
d2d46cb
Fixed assertEqualsWithDelta() assets.
landy2005 Nov 2, 2023
1c4c0cb
More fixes for assertEqualsWithDelta() assets.
landy2005 Nov 2, 2023
819ab69
More fixes for assertEqualsWithDelta() assets.
landy2005 Nov 2, 2023
55184ed
Reduce minimum php to 7.2.
landy2005 Nov 2, 2023
e76538b
Reduce minimum php to 7.2 for UnitTests.
landy2005 Nov 2, 2023
7976b05
Update CHANGELOG.md
landy2005 Nov 2, 2023
84e4398
Removed pow() function
landy2005 Nov 3, 2023
60cd6cf
Added HasIECUnitsTrait class. Generate all possible storage units.
landy2005 Nov 3, 2023
3014eb8
Added quetta and ronna Si/IEC prefixes.
landy2005 Nov 3, 2023
056d40b
Updated CHANGELOG.md
landy2005 Nov 3, 2023
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
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# .github/workflows/code_checks.yaml
name: Code_Checks

on: ["push", "pull_request"]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.2']
stability: [ prefer-stable ]
experimental: [false]
include:
- php: '7.2'
stability: prefer-lowest
- php: '7.3'
- php: '7.4'
- php: '8.0'
- php: '8.1'
- php: '8.2'

name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests
steps:
# basically git clone
- uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

# use PHP of specific version
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pcov
coverage: pcov

- name: Install dependencies
run: |
composer install --verbose --prefer-dist --no-interaction -o

- name: Execute tests
run: vendor/bin/phpunit -c ./tests/phpunit.xml.dist ./tests --verbose

cs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
coverage: none # disable xdebug, pcov
- run: composer install --no-progress
- run: ./vendor/bin/phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ Desktop.ini

# Vagrant files
/.vagrant/

.phpunit.result.cache
tests/clover.xml
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## v2.2.2 (November 3nd, 2023)
- Added ronna (R) and quetta (Q) si prefixes.
- Added IEC prefixed units support for Storage
- Added Storage units

## v2.2.1 (November 2nd, 2023)
- Drop support of php < 7.2

## v2.2.0 (February 17th, 2021)
- Added support for php 8.0
- Added option power factor for Si factor, ie for square (2) and cubic (3)
- Added new Physical Quantity volume flow with commonly used units
- Added lowercase aliases for temperature units
- Added Si prefixes for area unit square meter (m^2)
- Added Si prefixes for volume units cubic meter (m^3) and litres
- Added Si prefixes for velocity units m/s, m/min and m/h
- Added Si prefixes for acceleration unit m/s^2
- Additional units for energy: electronvolt, calorie
- Additional units for length: light year, parsec
- Additional units for mass: Hundredweight, US short Ton, US long Ton, Asian picul
- Additional units for pressure: Torr, Technical atmosphere, Kilo and Mega pound per Square Inch
- Additional units for velocity: Mach, meters/min, feet per minute, miles per second
- Additional unit for power: dBm
- Fixed native unit for mass as gram

## v2.1.0 (July 24th, 2016)
- Added getUnitDefinitions() method to PhysicalQuantity classes, to get a raw list of UnitofMeasure objects defined on that quantity
- Added UPPERCASE templating support for autogenerated metric units to support names like MEGA_METERS, for example.
Expand All @@ -7,7 +32,6 @@
- Additional units for time: decade, century, and millenium
- Additional units for volume: teaspoon, tablespoon, gallon, quart, fluid ounce, and pint


## v2.0.1 (December 12th, 2015)
- Migrated package from triplepoint/php-units-of-measure to php-units-of-measure/php-units-of-measure.
- New physical quantity: Energy
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# PHP Units of Measure
master: [![Build Status](https://travis-ci.org/PhpUnitsOfMeasure/php-units-of-measure.png?branch=master)](https://travis-ci.org/PhpUnitsOfMeasure/php-units-of-measure)
master: [![Build Status](https://travis-ci.org/landy2005/php-units-of-measure.png?branch=master)](https://travis-ci.org/landy2005/php-units-of-measure)

## Introduction
This is a PHP library for representing and converting physical units of measure. The utility of this library is in encapsulating physical quantities in such a way that you don't have to keep track of which unit they're represented in. For instance:
Expand Down Expand Up @@ -43,17 +43,17 @@ isTooTallToRideThisTrain( new Length(2, 'm') );
```

## Installation
This library is best included in your projects via Composer. See the [Composer website](http://getcomposer.org/) for more details, and see the [Packagist.org site for this library](https://packagist.org/packages/php-units-of-measure/php-units-of-measure).
This library is best included in your projects via Composer. See the [Composer website](https://getcomposer.org/) for more details, and see the [Packagist.org site for this library](https://packagist.org/packages/php-units-of-measure/php-units-of-measure).

If you'd prefer to manually include this library as a dependency in your project, then it is recommended that you use a [PSR-4](http://www.php-fig.org/psr/psr-4/) compliant PHP autoloader. The mapping between this project's root namespace and its base directory is:
If you'd prefer to manually include this library as a dependency in your project, then it is recommended that you use a [PSR-4](https://www.php-fig.org/psr/psr-4/) compliant PHP autoloader. The mapping between this project's root namespace and its base directory is:
- vendor namespace 'PhpUnitsOfMeasure\' maps to the library's base directory 'source/'

See the documentation of your autoloader for further instructions.

### Project Tags and Versions
This project follows the guidelines set out in [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html). In general, versions are of the form 'X.Y.Z', and increments to X denote backward-incompatible major changes.
This project follows the guidelines set out in [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html). In general, versions are of the form 'X.Y.Z', and increments to X denote backward-incompatible major changes.

It is recommended that if your project includes this project as a dependency and you are using an automated dependency management tool such as [Composer](http://getcomposer.org/), then you should 'pin' the major version (X) and allow only variations in 'Y' (minor changes) and 'Z' (bugfixes). See the documentation of your dependency manager for more details.
It is recommended that if your project includes this project as a dependency and you are using an automated dependency management tool such as [Composer](https://getcomposer.org/), then you should 'pin' the major version (X) and allow only variations in 'Y' (minor changes) and 'Z' (bugfixes). See the documentation of your dependency manager for more details.


## Use
Expand Down Expand Up @@ -239,7 +239,7 @@ class Length extends AbstractPhysicalQuantity
Now any program which uses `Length` will start with the cubits unit already built in. Note that here we used the more concise linear unit factory method, but the result is equivalent to the expanded form calling the `UnitOfMeasure` constructor, as used above. Also, notice that the `static` keyword was used instead of the class name, though either would be acceptable in this case.

### Adding New Physical Quantities
[Physical quantities](http://en.wikipedia.org/wiki/Physical_quantity) are categories of measurable values, like mass, length, force, etc.
[Physical quantities](https://en.wikipedia.org/wiki/Physical_quantity) are categories of measurable values, like mass, length, force, etc.

For physical quantities that are not already present in this library, it will be necessary to write a class to support a new one. All physical quantities implement the `\PhpUnitsOfMeasure\PhysicalQuantityInterface` interface, typically extend the `\PhpUnitsOfMeasure\AbstractPhysicalQuantity` class, and typically have only an `initialize()` method which creates the quantity's units of measure. See above for typical examples of physical quantity classes and of how to add new units to a quantity class.

Expand Down Expand Up @@ -307,16 +307,16 @@ composer.phar update --verbose --prefer-dist
All the tests associated with this project can be manually run with:

``` bash
vendor/bin/phpunit -c ./tests/phpunit.xml.dist ./tests
composer test
```

### CodeSniffer
Codesniffer verifies that coding standards are being met. Once the project is built with development dependencies, you can run the checks with:

``` bash
vendor/bin/phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./
composer phpcs
```

### Continuous Integration
The above tests are automatically run against Github commits with Travis-CI.
- https://travis-ci.org/PhpUnitsOfMeasure/php-units-of-measure
- https://travis-ci.org/landy2005/php-units-of-measure
14 changes: 11 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,25 @@
},

"require": {
"php": ">=5.5.0"
"php": ">=7.2"
},

"require-dev": {
"phpunit/phpunit": "4.8.*",
"squizlabs/php_codesniffer": "2.8.1"
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.7"
},

"replace": {
"triplepoint/php-units-of-measure": "*"
},

"scripts": {
"test": [
"@putenv XDEBUG_MODE=coverage",
"phpunit -c ./tests/phpunit.xml.dist ./tests"
],
"phpcs": "phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./"
},

"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion source/AbstractPhysicalQuantity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class AbstractPhysicalQuantity implements PhysicalQuantityInterface
*/
private static function buildUnitCacheKey($unit)
{
return get_called_class() . '#' . $unit;
return static::class . '#' . $unit;
}

/**
Expand Down
Loading