Apply fixes from StyleCI

This commit is contained in:
Nabeel Shahzad
2018-08-26 16:40:04 +00:00
committed by StyleCI Bot
parent 20f46adbc4
commit 9596d88b48
407 changed files with 4032 additions and 3286 deletions

View File

@@ -8,12 +8,12 @@ use Symfony\Component\ClassLoader\ClassMapGenerator;
/**
* Class find/load related functionality. Is used to find
* the award classes right now that might be in a module
* @package App\Support
*/
class ClassLoader
{
/**
* @param $path
*
* @return array
*/
public static function getClassesInPath($path): array
@@ -26,7 +26,7 @@ class ClassLoader
$all_classes = array_keys(ClassMapGenerator::createMap($path));
foreach ($all_classes as $cl) {
try {
$klass = new $cl;
$klass = new $cl();
} catch (\Exception $e) {
Log::error('Error loading class: '.$e->getMessage());
continue;

View File

@@ -4,17 +4,17 @@ namespace App\Support;
/**
* Class Countries
* @package App\Support
*/
class Countries
{
/**
* Get a select box list of all the countries
*
* @return static
*/
public static function getSelectList()
{
$countries = collect((new \League\ISO3166\ISO3166)->all())
$countries = collect((new \League\ISO3166\ISO3166())->all())
->mapWithKeys(function ($item, $key) {
return [strtolower($item['alpha2']) => $item['name']];
});

View File

@@ -1,16 +1,12 @@
<?php
/**
*
*/
namespace App\Support;
use Carbon\Carbon;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
use Symfony\Component\Yaml\Yaml;
use Webpatser\Uuid\Uuid;
use Log;
use Symfony\Component\Yaml\Yaml;
class Database
{
@@ -25,8 +21,10 @@ class Database
/**
* @param $yaml_file
* @param bool $ignore_errors
* @return array
*
* @throws \Exception
*
* @return array
*/
public static function seed_from_yaml_file($yaml_file, $ignore_errors = false): array
{
@@ -37,8 +35,10 @@ class Database
/**
* @param $yml
* @param bool $ignore_errors
* @return array
*
* @throws \Exception
*
* @return array
*/
public static function seed_from_yaml($yml, $ignore_errors = false): array
{
@@ -58,7 +58,7 @@ class Database
throw $e;
}
++$imported[$table];
$imported[$table]++;
}
}
@@ -66,19 +66,21 @@ class Database
}
/**
* @param $table
* @param $row
* @return mixed
* @param $table
* @param $row
*
* @throws \Exception
*
* @return mixed
*/
public static function insert_row($table, $row)
{
# encrypt any password fields
// encrypt any password fields
if (array_key_exists('password', $row)) {
$row['password'] = bcrypt($row['password']);
}
# if any time fields are == to "now", then insert the right time
// if any time fields are == to "now", then insert the right time
foreach ($row as $column => $value) {
if (strtolower($value) === 'now') {
$row[$column] = static::time();
@@ -89,6 +91,7 @@ class Database
DB::table($table)->insert($row);
} catch (QueryException $e) {
Log::error($e);
throw $e;
}

View File

@@ -8,7 +8,9 @@ class Dates
{
/**
* Get the list of months, given a start date
*
* @param Carbon $start_date
*
* @return array
*/
public static function getMonthsList(Carbon $start_date)
@@ -28,7 +30,9 @@ class Dates
/**
* Return the start/end dates for a given month/year
*
* @param $month YYYY-MM
*
* @return array
*/
public static function getMonthBoundary($month)
@@ -38,7 +42,7 @@ class Dates
return [
"$year-$month-01",
"$year-$month-$days"
"$year-$month-$days",
];
}
}

View File

@@ -6,17 +6,19 @@ use GuzzleHttp\Client;
/**
* Helper for HTTP stuff
* @package App\Support
*/
class Http
{
/**
* Download a URI. If a file is given, it will save the downloaded
* content into that file
*
* @param $uri
* @param array $opts
* @return string
*
* @throws \GuzzleHttp\Exception\GuzzleException
*
* @return string
*/
public static function get($uri, array $opts)
{

View File

@@ -4,14 +4,15 @@ namespace App\Support;
/**
* ICAO Helper Tools
* @package App\Support
*/
class ICAO
{
/**
* Create a random hex code. Eventually this may follow the format in:
* ICAO Aeronautical Telecommunications, Annex 10, Vol. III, chapter 9
*
* @param null $country
*
* @return string
*/
public static function createHexCode($country = null)

View File

@@ -4,15 +4,16 @@ namespace App\Support;
/**
* Helper math
* @package App\Support
*/
class Math
{
/**
* Determine from the base rate, if we want to return the overridden rate
* or if the overridden rate is a percentage, then return that amount
*
* @param $base_rate
* @param $override_rate
*
* @return float|null
*/
public static function applyAmountOrPercent($base_rate, $override_rate = null): ?float
@@ -21,7 +22,7 @@ class Math
return $base_rate;
}
# Not a percentage override
// Not a percentage override
if (substr_count($override_rate, '%') === 0) {
return $override_rate;
}
@@ -31,8 +32,10 @@ class Math
/**
* Add/subtract a percentage to a number
*
* @param $number
* @param $percent
*
* @return float
*/
public static function addPercent($number, $percent): float

View File

@@ -8,10 +8,6 @@ use App\Support\Units\Temperature;
/**
* Class Metar
* @package App\Support
*
* Modified by Nabeel S, adapted for phpVMS
* Copyright left intact below!
*/
/*
@@ -174,12 +170,12 @@ class Metar implements \ArrayAccess
'CLR' => 'clear skies',
'NOBS' => 'no observation',
//
'FEW' => 'a few',
'SCT' => 'scattered',
'BKN' => 'broken sky',
'OVC' => 'overcast sky',
'FEW' => 'a few',
'SCT' => 'scattered',
'BKN' => 'broken sky',
'OVC' => 'overcast sky',
//
'VV' => 'vertical visibility',
'VV' => 'vertical visibility',
];
/*
@@ -331,6 +327,7 @@ class Metar implements \ArrayAccess
* UKDR 251830Z 00000MPS CAVOK 08/07 Q1019 3619//60 NOSIG
* UBBB 251900Z 34015KT 9999 FEW013 BKN030 16/14 Q1016 88CLRD70 NOSIG
* UMMS 251936Z 19002MPS 9999 SCT006 OVC026 06/05 Q1015 R31/D NOSIG RMK QBB080 OFE745
*
* @param $raw
* @param bool $taf
* @param bool $debug
@@ -367,8 +364,10 @@ class Metar implements \ArrayAccess
/**
* Shortcut to call
*
* @param $metar
* @param string $taf
*
* @return mixed
*/
public static function parse($metar, $taf = '')
@@ -379,7 +378,9 @@ class Metar implements \ArrayAccess
/**
* Gets the value from result array as class property.
*
* @param $parameter
*
* @return mixed|null
*/
public function __get($parameter)
@@ -387,8 +388,6 @@ class Metar implements \ArrayAccess
if (isset($this->result[$parameter])) {
return $this->result[$parameter];
}
return null;
}
/**
@@ -436,10 +435,10 @@ class Metar implements \ArrayAccess
}
// Finally determine if it's VFR or IFR conditions
// https://www.aviationweather.gov/cva/help
if(array_key_exists('cavok', $this->result) && $this->result['cavok']) {
if (array_key_exists('cavok', $this->result) && $this->result['cavok']) {
$this->result['category'] = 'VFR';
} else {
if(array_key_exists('cloud_height', $this->result) && array_key_exists('visibility', $this->result)) {
if (array_key_exists('cloud_height', $this->result) && array_key_exists('visibility', $this->result)) {
if ($this->result['cloud_height']['ft'] > 3000 && $this->result['visibility']['nmi'] > 5) {
$this->result['category'] = 'VFR';
} else {
@@ -471,6 +470,8 @@ class Metar implements \ArrayAccess
* This method formats observation date and time in the local time zone of server,
* the current local time on server, and time difference since observation. $time_utc is a
* UNIX timestamp for Universal Coordinated Time (Greenwich Mean Time or Zulu Time).
*
* @param mixed $time_utc
*/
private function set_observed_date($time_utc)
{
@@ -483,12 +484,13 @@ class Metar implements \ArrayAccess
if ($time_diff < 91) {
$this->set_result_value('observed_age', $time_diff.' '.trans_choice('widgets.weather.minago', $time_diff));
} else {
$this->set_result_value('observed_age', floor($time_diff / 60).':'.sprintf("%02d", $time_diff % 60).' '.trans_choice('widgets.weather.hrago', floor($time_diff / 60)));
$this->set_result_value('observed_age', floor($time_diff / 60).':'.sprintf('%02d', $time_diff % 60).' '.trans_choice('widgets.weather.hrago', floor($time_diff / 60)));
}
}
/**
* Sets the new value to parameter in result array.
*
* @param $parameter
* @param $value
* @param bool $only_if_null
@@ -506,6 +508,9 @@ class Metar implements \ArrayAccess
/**
* Sets the data group to parameter in result array.
*
* @param mixed $parameter
* @param mixed $group
*/
private function set_result_group($parameter, $group)
{
@@ -518,6 +523,7 @@ class Metar implements \ArrayAccess
/**
* Sets the report text to parameter in result array.
*
* @param $parameter
* @param $report
* @param string $separator
@@ -532,6 +538,8 @@ class Metar implements \ArrayAccess
/**
* Adds the debug text to debug information array.
*
* @param mixed $text
*/
private function set_debug($text)
{
@@ -542,6 +550,8 @@ class Metar implements \ArrayAccess
/**
* Adds the error text to parse errors array.
*
* @param mixed $text
*/
private function set_error($text)
{
@@ -551,8 +561,11 @@ class Metar implements \ArrayAccess
// --------------------------------------------------------------------
// Methods for parsing raw parts
// --------------------------------------------------------------------
/**
* Decodes TAF code if present.
*
* @param mixed $part
*/
private function get_taf($part)
{
@@ -573,6 +586,8 @@ class Metar implements \ArrayAccess
/**
* Decodes station code.
*
* @param mixed $part
*/
private function get_station($part)
{
@@ -589,6 +604,8 @@ class Metar implements \ArrayAccess
/**
* Decodes observation time.
* Format is ddhhmmZ where dd = day, hh = hours, mm = minutes in UTC time.
*
* @param mixed $part
*/
private function get_time($part)
{
@@ -627,6 +644,8 @@ class Metar implements \ArrayAccess
/**
* Ignore station type if present.
*
* @param mixed $part
*/
private function get_station_type($part)
{
@@ -643,7 +662,9 @@ class Metar implements \ArrayAccess
* Format is dddssKT where ddd = degrees from North, ss = speed, KT for knots,
* or dddssGggKT where G stands for gust and gg = gust speed. (ss or gg can be a 3-digit number.)
* KT can be replaced with MPH for meters per second or KMH for kilometers per hour.
*
* @param $part
*
* @return bool
*/
private function get_wind($part)
@@ -724,6 +745,9 @@ class Metar implements \ArrayAccess
* if visibility is limited to an integer mile plus a fraction part.
* Format is mmSM for mm = statute miles, or m n/dSM for m = mile and n/d = fraction of a mile,
* or just a 4-digit number nnnn (with leading zeros) for nnnn = meters.
*
* @param mixed $part
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
*/
@@ -792,11 +816,14 @@ class Metar implements \ArrayAccess
* (if the visibility is better than 10 km, 9999 is used. 9999 means a minimum
* visibility of 50 m or less), and for DD = the approximate direction of minimum and
* maximum visibility is given as one of eight compass points (N, SW, ...).
*
* @param $part
* @return bool
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*
* @return bool
*/
private function get_visibility_min($part)
{
@@ -819,10 +846,13 @@ class Metar implements \ArrayAccess
* Decodes runway visual range information if present.
* Format is Rrrr/vvvvFT where rrr = runway number, vvvv = visibility,
* and FT = the visibility in feet.
*
* @param $part
* @return bool
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
*
* @return bool
*/
private function get_runway_vr($part)
{
@@ -911,7 +941,9 @@ class Metar implements \ArrayAccess
* to decode all conditions. To learn more about weather condition codes, visit section
* 12.6.8 - Present Weather Group of the Federal Meteorological Handbook No. 1 at
* www.nws.noaa.gov/oso/oso1/oso12/fmh1/fmh1ch12.htm
*
* @param $part
*
* @return bool
*/
private function get_present_weather($part)
@@ -925,10 +957,13 @@ class Metar implements \ArrayAccess
* Format is SKC or CLR for clear skies, or cccnnn where ccc = 3-letter code and
* nnn = height of cloud layer in hundreds of feet. 'VV' seems to be used for
* very low cloud layers.
*
* @param $part
* @return bool
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
*
* @return bool
*/
private function get_clouds($part)
{
@@ -942,10 +977,10 @@ class Metar implements \ArrayAccess
}
$observed = [
'amount' => null,
'height' => null,
'type' => null,
'report' => null,
'amount' => null,
'height' => null,
'type' => null,
'report' => null,
];
// Clear skies or no observation
@@ -984,8 +1019,8 @@ class Metar implements \ArrayAccess
$report[] = 'at '.round($observed['height']['m'], 0).' meters, '.static::$cloud_type_codes[$observed['type']];
$report_ft[] = 'at '.round($observed['height']['ft'], 0).' feet, '.static::$cloud_type_codes[$observed['type']];
} else {
$report[] = 'at ' . round($observed['height']['m'], 0) . ' meters';
$report_ft[] = 'at ' . round($observed['height']['ft'], 0) . ' feet';
$report[] = 'at '.round($observed['height']['m'], 0).' meters';
$report_ft[] = 'at '.round($observed['height']['ft'], 0).' feet';
}
}
@@ -1009,6 +1044,9 @@ class Metar implements \ArrayAccess
* Format is tt/dd where tt = temperature and dd = dew point temperature. All units are
* in Celsius. A 'M' preceeding the tt or dd indicates a negative temperature. Some
* stations do not report dew point, so the format is tt/ or tt/XX.
*
* @param mixed $part
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
*/
@@ -1057,6 +1095,8 @@ class Metar implements \ArrayAccess
* 1 mm Hg = 25.4 in Hg = 0.750062 hPa
* 1 lb/sq in = 0.491154 in Hg = 0.014504 hPa
* 1 atm = 0.33421 in Hg = 0.0009869 hPa
*
* @param mixed $part
*/
private function get_pressure($part)
{
@@ -1079,6 +1119,8 @@ class Metar implements \ArrayAccess
/**
* Decodes recent weather conditions if present.
* Format is REww where ww = Weather phenomenon code (see get_present_weather above).
*
* @param mixed $part
*/
private function get_recent_weather($part)
{
@@ -1089,6 +1131,8 @@ class Metar implements \ArrayAccess
* Decodes runways report information if present.
* Format rrrECeeBB or Rrrr/ECeeBB where rr = runway number, E = deposits,
* C = extent of deposit, ee = depth of deposit, BB = friction coefficient.
*
* @param mixed $part
*/
private function get_runways_report($part)
{
@@ -1195,6 +1239,8 @@ class Metar implements \ArrayAccess
/**
* Decodes wind shear information if present.
* Format is 'WS ALL RWY' or 'WS RWYdd' where dd = Runway designator (see get_runway_vr above).
*
* @param mixed $part
*/
private function get_wind_shear($part)
{
@@ -1211,7 +1257,6 @@ class Metar implements \ArrayAccess
$this->part += 2; // can skip neext parts with ALL and RWY records
} // See one next part for RWYdd record
elseif (isset($this->raw_parts[$this->part])) {
$r = '@^R(WY)?' // 1
.'([\d]{2}[LCR]?)$@'; // 2
@@ -1234,17 +1279,20 @@ class Metar implements \ArrayAccess
/**
* Decodes max and min temperature forecast information if present.
*
* @param string $part
* Format TXTtTt/ddHHZ or TNTtTt/ddHHZ, where:
* TX - Indicator for Maximum temperature
* TN - Indicator for Minimum temperature
* TtTt - Temperature value in Celsius
* dd - Forecast day of month
* HH - Forecast hour, i.e. the time(hour) when the temperature is expected
* Z - Time Zone indicator, Z=GMT.
* @return bool
* Format TXTtTt/ddHHZ or TNTtTt/ddHHZ, where:
* TX - Indicator for Maximum temperature
* TN - Indicator for Minimum temperature
* TtTt - Temperature value in Celsius
* dd - Forecast day of month
* HH - Forecast hour, i.e. the time(hour) when the temperature is expected
* Z - Time Zone indicator, Z=GMT.
*
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
*
* @return bool
*/
private function get_forecast_temperature($part): bool
{
@@ -1262,9 +1310,9 @@ class Metar implements \ArrayAccess
$temperture = new Temperature($temperature_c, 'C');
$forecast = [
'value' => $temperture,
'day' => null,
'time' => null,
'value' => $temperture,
'day' => null,
'time' => null,
];
if (!empty($found[3])) {
@@ -1286,6 +1334,8 @@ class Metar implements \ArrayAccess
* Decodes trends information if present.
* All METAR trend and TAF records is beginning at: NOSIG, BECMG, TEMP, ATDDhhmm, FMDDhhmm,
* LTDDhhmm or DDhh/DDhh, where hh = hours, mm = minutes, DD = day of month.
*
* @param mixed $part
*/
private function get_trends($part)
{
@@ -1447,7 +1497,9 @@ class Metar implements \ArrayAccess
/**
* Get remarks information if present.
* The information is everything that comes after RMK.
*
* @param string $part
*
* @return bool
*/
private function get_remarks($part): bool
@@ -1460,7 +1512,7 @@ class Metar implements \ArrayAccess
$remarks = [];
// Get all parts after
while ($this->part < sizeof($this->raw_parts)) {
while ($this->part < count($this->raw_parts)) {
if (isset($this->raw_parts[$this->part])) {
$remarks[] = $this->raw_parts[$this->part];
}
@@ -1477,9 +1529,11 @@ class Metar implements \ArrayAccess
/**
* Decodes present or recent weather conditions.
*
* @param $part
* @param $method
* @param string $regexp_prefix
*
* @return bool
*/
private function decode_weather($part, $method, $regexp_prefix = '')
@@ -1550,8 +1604,10 @@ class Metar implements \ArrayAccess
/**
* Calculate Heat Index based on temperature in F and relative humidity (65 = 65%)
*
* @param $temperature_f
* @param $rh
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/
@@ -1572,7 +1628,9 @@ class Metar implements \ArrayAccess
/**
* Calculate Wind Chill Temperature based on temperature in F
* and wind speed in miles per hour.
*
* @param $temperature_f
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/
@@ -1599,8 +1657,10 @@ class Metar implements \ArrayAccess
* 1 knot = 1.852 km/hr = 0.514444 m/s = 1.687809 ft/s = 1.150779 mi/hr
* 1 km/hr = 0.539957 knots = 0.277778 m/s = 0.911344 ft/s = 0.621371 mi/hr
* 1 m/s = 1.943844 knots = 3.6 km/h = 3.28084 ft/s = 2.236936 mi/hr
*
* @param $speed
* @param $unit
*
* @return float|null
*/
private function convert_speed($speed, $unit)
@@ -1615,8 +1675,6 @@ class Metar implements \ArrayAccess
case 'MPS':
return round($speed, 2); // m/s
}
return null;
}
/**
@@ -1625,8 +1683,10 @@ class Metar implements \ArrayAccess
* 1 m = 3.28084 ft = 0.00062 mi
* 1 ft = 0.3048 m = 0.00019 mi
* 1 mi = 5279.99 ft = 1609.34 m
*
* @param $distance
* @param $unit
*
* @return float|null
*/
private function convert_distance($distance, $unit)
@@ -1640,36 +1700,40 @@ class Metar implements \ArrayAccess
case 'M':
return round($distance); // meters
}
return null;
}
/**
* Convert direction degrees to compass label.
*
* @param mixed $direction
*/
private function convert_direction_label($direction)
{
if ($direction >= 0 && $direction <= 360) {
return static::$direction_codes[round($direction / 22.5) % 16];
}
return null;
}
/**
* These methods below the implementation of the stubs for ArrayAccess
*
* @param mixed $offset
*/
/**
* Whether a offset exists
*
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
*
* @param mixed $offset <p>
* An offset to check for.
* </p>
* @return boolean true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
*
* @return bool true on success or false on failure.
* </p>
* <p>
* The return value will be casted to boolean if non-boolean was returned.
*
* @since 5.0.0
*/
public function offsetExists($offset)
@@ -1679,11 +1743,15 @@ class Metar implements \ArrayAccess
/**
* Offset to retrieve
*
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
* @param mixed $offset <p>
* The offset to retrieve.
* </p>
*
* @return mixed Can return all value types.
*
* @since 5.0.0
*/
public function offsetGet($offset)
@@ -1693,14 +1761,18 @@ class Metar implements \ArrayAccess
/**
* Offset to set
*
* @link http://php.net/manual/en/arrayaccess.offsetset.php
*
* @param mixed $offset <p>
* The offset to assign the value to.
* </p>
* @param mixed $value <p>
* The value to set.
* </p>
*
* @return void
*
* @since 5.0.0
*/
public function offsetSet($offset, $value)
@@ -1710,11 +1782,15 @@ class Metar implements \ArrayAccess
/**
* Offset to unset
*
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
*
* @param mixed $offset <p>
* The offset to unset.
* </p>
*
* @return void
*
* @since 5.0.0
*/
public function offsetUnset($offset)

View File

@@ -1,7 +1,4 @@
<?php
/**
*
*/
namespace App\Support;
@@ -10,7 +7,6 @@ use Akaunting\Money\Money as MoneyBase;
/**
* Compositional wrapper to MoneyPHP with some helpers
* @package App\Support
*/
class Money
{
@@ -21,9 +17,11 @@ class Money
/**
* @param mixed $amount
* @return MoneyBase
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return MoneyBase
*/
public static function create($amount)
{
@@ -32,21 +30,26 @@ class Money
/**
* Create from a dollar amount
*
* @param mixed $amount
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public static function createFromAmount($amount)
{
return new Money(
return new self(
static::convertToSubunit($amount)
);
}
/**
* Convert a whole unit into it's subunit, e,g: dollar to cents
*
* @param mixed $amount
*
* @return float|int
*/
public static function convertToSubunit($amount)
@@ -58,8 +61,10 @@ class Money
/**
* Create a new currency object using the currency setting
* Fall back to USD if it's not valid
* @return Currency
*
* @throws \OutOfBoundsException
*
* @return Currency
*/
public static function currency()
{
@@ -72,7 +77,9 @@ class Money
/**
* Money constructor.
*
* @param mixed $amount
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
@@ -83,6 +90,7 @@ class Money
/**
* Return the amount of currency in smallest denomination
*
* @return string
*/
public function getAmount()
@@ -101,6 +109,7 @@ class Money
/**
* Returns the value in whole amounts, e.g: 100.00
* instead of returning in the smallest denomination
*
* @return float
*/
public function getValue()
@@ -133,7 +142,6 @@ class Money
}
/**
*
* @return string
*/
public function __toString()
@@ -143,10 +151,13 @@ class Money
/**
* Add an amount
*
* @param mixed $amount
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function add($amount)
{
@@ -161,9 +172,11 @@ class Money
/**
* @param mixed $percent
* @return $this
*
* @throws \OutOfBoundsException
* @throws \InvalidArgumentException
*
* @return $this
*/
public function addPercent($percent)
{
@@ -179,10 +192,13 @@ class Money
/**
* Subtract an amount
*
* @param $amount
* @return Money
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function subtract($amount)
{
@@ -197,11 +213,14 @@ class Money
/**
* Multiply by an amount
*
* @param $amount
* @return Money
*
* @throws \UnexpectedValueException
* @throws \OutOfBoundsException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function multiply($amount)
{
@@ -216,10 +235,13 @@ class Money
/**
* Divide by an amount
*
* @param $amount
* @return Money
*
* @throws \OutOfBoundsException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function divide($amount)
{
@@ -229,9 +251,11 @@ class Money
/**
* @param $money
* @return bool
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return bool
*/
public function equals($money)
{

View File

@@ -2,7 +2,6 @@
namespace App\Support;
use DateTime;
use DateTimeZone;
use Jackiedo\Timezonelist\Timezonelist;
@@ -11,14 +10,15 @@ class TimezonelistExtended extends Timezonelist
/**
* Format to display timezones
*
* @param string $timezone
* @param string $continent
* @param bool $htmlencode
* @param string $timezone
* @param string $continent
* @param bool $htmlencode
*
* @return string
*/
protected function formatTimezone($timezone, $continent, $htmlencode=true)
protected function formatTimezone($timezone, $continent, $htmlencode = true)
{
$time = new DateTime(null, new DateTimeZone($timezone));
$time = new \DateTimeImmutable(null, new DateTimeZone($timezone));
$offset = $time->format('P');
if ($htmlencode) {
$offset = str_replace('-', ' &minus; ', $offset);
@@ -27,7 +27,7 @@ class TimezonelistExtended extends Timezonelist
$timezone = substr($timezone, strlen($continent) + 1);
$timezone = str_replace('St_', 'St. ', $timezone);
$timezone = str_replace('_', ' ', $timezone);
$formatted = '(GMT/UTC' . $offset . ')' . self::WHITESPACE_SEP . $timezone;
$formatted = '(GMT/UTC'.$offset.')'.self::WHITESPACE_SEP.$timezone;
return $formatted;
}
@@ -36,41 +36,42 @@ class TimezonelistExtended extends Timezonelist
*
* @param string $name
* @param string $selected
* @param mixed $attr
* @param bool $htmlencode
* @param mixed $attr
* @param bool $htmlencode
*
* @return string
*/
public function create($name, $selected='', $attr='', $htmlencode=true)
public function create($name, $selected = '', $attr = '', $htmlencode = true)
{
// Attributes for select element
$attrSet = '';
if (!empty($attr)) {
if (is_array($attr)) {
foreach ($attr as $attr_name => $attr_value) {
$attrSet .= ' ' .$attr_name. '="' .$attr_value. '"';
$attrSet .= ' '.$attr_name.'="'.$attr_value.'"';
}
} else {
$attrSet = ' ' .$attr;
$attrSet = ' '.$attr;
}
}
// start select element
$listbox = '<select name="' .$name. '"' .$attrSet. '>';
$listbox = '<select name="'.$name.'"'.$attrSet.'>';
// Add popular timezones
$listbox .= '<optgroup label="General">';
foreach ($this->popularTimezones as $key => $value) {
$selected_attr = ($selected == $key) ? ' selected="selected"' : '';
$listbox .= '<option value="' .$key. '"' .$selected_attr. '>' .$value. '</option>';
$listbox .= '<option value="'.$key.'"'.$selected_attr.'>'.$value.'</option>';
}
$listbox .= '</optgroup>';
// Add all timezone of continents
foreach ($this->continents as $continent => $mask) {
$timezones = DateTimeZone::listIdentifiers($mask);
// start optgroup tag
$listbox .= '<optgroup label="' .$continent. '">';
$listbox .= '<optgroup label="'.$continent.'">';
// create option tags
foreach ($timezones as $timezone) {
$selected_attr = ($selected == $timezone) ? ' selected="selected"' : '';
$listbox .= '<option value="' .$timezone. '"' .$selected_attr. '>';
$listbox .= '<option value="'.$timezone.'"'.$selected_attr.'>';
$listbox .= $this->formatTimezone($timezone, $continent, $htmlencode);
$listbox .= '</option>';
}
@@ -86,9 +87,10 @@ class TimezonelistExtended extends Timezonelist
* Create a timezone array
*
* @param bool $htmlencode
*
* @return mixed
*/
public function toArray($htmlencode=false)
public function toArray($htmlencode = false)
{
$list = [];
// Add popular timezones to list
@@ -104,4 +106,4 @@ class TimezonelistExtended extends Timezonelist
}
return $list;
}
}
}

View File

@@ -5,14 +5,12 @@ namespace App\Support\Units;
use App\Interfaces\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Length;
/**
* @package App\Support\Units
*/
class Altitude extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/
@@ -23,7 +21,7 @@ class Altitude extends Unit
$this->units = [
'm' => round($this->instance->toUnit('meters'), 2),
'km' => round($this->instance->toUnit('meters') / 1000, 2),
'km' => round($this->instance->toUnit('meters') / 1000, 2),
'ft' => round($this->instance->toUnit('feet'), 2),
];
}

View File

@@ -5,15 +5,14 @@ namespace App\Support\Units;
use App\Interfaces\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Length;
/**
* @package App\Support\Units
*/
class Distance extends Unit
{
/**
* Distance constructor.
*
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/

View File

@@ -5,14 +5,12 @@ namespace App\Support\Units;
use App\Interfaces\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Mass;
/**
* @package App\Support\Units
*/
class Fuel extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/

View File

@@ -5,14 +5,12 @@ namespace App\Support\Units;
use App\Interfaces\Unit;
use PhpUnitsOfMeasure\PhysicalQuantity\Mass as MassUnit;
/**
* @package App\Support\Units
*/
class Mass extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/

View File

@@ -7,13 +7,13 @@ use PhpUnitsOfMeasure\PhysicalQuantity\Temperature as TemperatureUnit;
/**
* Composition for the converter
* @package App\Support\Units
*/
class Temperature extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/

View File

@@ -6,26 +6,27 @@ use Illuminate\Contracts\Support\Arrayable;
/**
* Class Time
* @package App\Support\Units
*/
class Time implements Arrayable
{
public $hours,
$minutes;
public $hours;
public $minutes;
/**
* @param $minutes
* @param $hours
*
* @return static
*/
public static function init($minutes, $hours)
{
return new Time($minutes, $hours);
return new self($minutes, $hours);
}
/**
* Pass just minutes to figure out how many hours
* Or both hours and minutes
*
* @param $minutes
* @param $hours
*/
@@ -44,6 +45,7 @@ class Time implements Arrayable
/**
* Get the total number minutes, adding up the hours
*
* @return float|int
*/
public function getMinutes()
@@ -53,7 +55,9 @@ class Time implements Arrayable
/**
* Alias to getMinutes()
*
* @alias getMinutes()
*
* @return float|int
*/
public function asInt()
@@ -63,6 +67,7 @@ class Time implements Arrayable
/**
* Return a time string
*
* @return string
*/
public function __toString()

View File

@@ -7,13 +7,13 @@ use PhpUnitsOfMeasure\PhysicalQuantity\Velocity as VelocityUnit;
/**
* Class Velocity
* @package App\Support\Units
*/
class Velocity extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/

View File

@@ -7,13 +7,13 @@ use PhpUnitsOfMeasure\PhysicalQuantity\Volume as VolumeUnit;
/**
* Wrap the converter class
* @package App\Support\Units
*/
class Volume extends Unit
{
/**
* @param float $value
* @param string $unit
*
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
*/