Skip to content

Commit fff0565

Browse files
authored
feat: add Velocity Units (pimlie#8)
* feat: added velocity unit type fix: Added correct unit systems to velocity units * added .idea to gitignore * fix: adjusted spelling, added aliases Added aliases for Mile based Velocity Units as per code review. * fix: Adjust test to account for added unit types
1 parent e158067 commit fff0565

20 files changed

+276
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea/
12
.git
23
clover.xml
34
coveralls-upload.json

src/Unit/Velocity.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit;
3+
4+
use PhpUnitConversion\Unit;
5+
use PhpUnitConversion\UnitType;
6+
7+
class Velocity extends Unit
8+
{
9+
const TYPE = UnitType::VELOCITY;
10+
11+
const BASE_UNIT = Velocity\MeterPerSecond::class;
12+
}

src/Unit/Velocity/FootPerHour.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class FootPerHour extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/11811;
11+
12+
const SYMBOL = 'fph';
13+
const LABEL = 'foot per hour';
14+
}

src/Unit/Velocity/FootPerMinute.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class FootPerMinute extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/196.85;
11+
12+
const SYMBOL = 'fpm';
13+
const LABEL = 'foot per minute';
14+
}

src/Unit/Velocity/FootPerSecond.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class FootPerSecond extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/3.280840;
11+
12+
const SYMBOL = 'fps';
13+
const LABEL = 'foot per second';
14+
}

src/Unit/Velocity/InchPerHour.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class InchPerHour extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/141732.3;
11+
12+
const SYMBOL = 'iph';
13+
const LABEL = 'inch per hour';
14+
}

src/Unit/Velocity/InchPerMinute.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class InchPerMinute extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/2362.205;
11+
12+
const SYMBOL = 'ipm';
13+
const LABEL = 'inch per minute';
14+
}

src/Unit/Velocity/InchPerSecond.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Imperial;
5+
use PhpUnitConversion\System\USC;
6+
use PhpUnitConversion\Unit\Velocity;
7+
8+
class InchPerSecond extends Velocity implements Imperial, USC
9+
{
10+
const FACTOR = 1/39.37008;
11+
12+
const SYMBOL = 'ips';
13+
const LABEL = 'inch per second';
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Metric;
5+
use PhpUnitConversion\Unit\Velocity;
6+
7+
class KiloMeterPerHour extends Velocity implements Metric
8+
{
9+
const FACTOR = 1/3.6;
10+
11+
const SYMBOL = 'km/h';
12+
const LABEL = 'kilometer per hour';
13+
}

src/Unit/Velocity/Knot.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
namespace PhpUnitConversion\Unit\Velocity;
3+
4+
use PhpUnitConversion\System\Metric;
5+
use PhpUnitConversion\Unit\Velocity;
6+
7+
class Knot extends Velocity implements Metric
8+
{
9+
const FACTOR = 1/1.943844;
10+
11+
const SYMBOL = 'kn';
12+
const LABEL = 'knot';
13+
}

0 commit comments

Comments
 (0)