-
Notifications
You must be signed in to change notification settings - Fork 3
New currency #13
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
Open
adeptofvoltron
wants to merge
7
commits into
purringCatFoundation:master
Choose a base branch
from
adeptofvoltron:new_currency
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New currency #13
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,107 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| use PCF\ValueObject\ValueObjectInterface; | ||
|
|
||
| abstract class AbstractCurrency implements ValueObjectInterface | ||
| { | ||
|
|
||
| public const FULL_NAME = ''; | ||
| public const SUBUNIT = ''; | ||
| public const ISO_CODE = ''; | ||
| public const SYMBOL = ''; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 1; | ||
| protected const SYMBOL_FIRST = false; | ||
|
|
||
| /** | ||
| * @var integer | ||
| */ | ||
| protected $subUnitQuality; | ||
|
|
||
| /** | ||
| * AbstractCurrency constructor. | ||
| * @param float $quality | ||
| * @param int $subUnitQuality | ||
| */ | ||
| public function __construct($quality = null, $subUnitQuality = null) | ||
| { | ||
| if (false === empty($subUnitQuality)) { | ||
| $this->subUnitQuality = $subUnitQuality; | ||
| } elseif (false === empty($quality)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange if-else code block. What if both was not empty ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. than I throw an exception |
||
| $this->subUnitQuality = intval($quality * static::SUBUNIT_TO_UNIT); | ||
| } else { | ||
| throw new \InvalidArgumentException('quality or subunit quality required'); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| public function isEqualTo(ValueObjectInterface $compare): bool | ||
| { | ||
| if (!$compare instanceof AbstractCurrency || !$compare instanceof static::class) { | ||
| throw new \InvalidArgumentException('You may compare only same currency'); | ||
| } | ||
| return $compare->getQuality() == $this->getQuality(); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| public function __toString(): string | ||
| { | ||
| return ($this->subUnitQuality / static::SUBUNIT_TO_UNIT) . ' ' . static::SYMBOL; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getSubUnitQuality() | ||
| { | ||
| return $this->subUnitQuality . ' ' . static::SUBUNIT; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getSymbol() | ||
| { | ||
| return static::SYMBOL; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getName() | ||
| { | ||
| return static::FULL_NAME; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getSubUnit() | ||
| { | ||
| return static::SUBUNIT; | ||
| } | ||
|
|
||
| /** | ||
| * @return float | ||
| */ | ||
| public function getQuality() | ||
| { | ||
| return $this->subUnitQuality / static::SUBUNIT_TO_UNIT; | ||
| } | ||
|
|
||
| /** | ||
| * @return int | ||
| */ | ||
| public function getSubQuality() | ||
| { | ||
| return $this->subUnitQuality; | ||
| } | ||
| } | ||
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AfghanAfghani extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Afghan Afghani'; | ||
| public const SUBUNIT = 'Pul'; | ||
| public const ISO_CODE = 'AFN'; | ||
| public const SYMBOL = 'Ø‹'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AlbanianLek extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Albanian Lek'; | ||
| public const SUBUNIT = 'Qintar'; | ||
| public const ISO_CODE = 'ALL'; | ||
| public const SYMBOL = 'L'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AlgerianDinar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Algerian Dinar'; | ||
| public const SUBUNIT = 'Centime'; | ||
| public const ISO_CODE = 'DZD'; | ||
| public const SYMBOL = 'د.ج'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AngolanKwanza extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Angolan Kwanza'; | ||
| public const SUBUNIT = 'Cêntimo'; | ||
| public const ISO_CODE = 'AOA'; | ||
| public const SYMBOL = 'Kz'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class ArgentinePeso extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Argentine Peso'; | ||
| public const SUBUNIT = 'Centavo'; | ||
| public const ISO_CODE = 'ARS'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class ArmenianDram extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Armenian Dram'; | ||
| public const SUBUNIT = 'Luma'; | ||
| public const ISO_CODE = 'AMD'; | ||
| public const SYMBOL = 'Õ¤Ö€.'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class ArubanFlorin extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Aruban Florin'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'AWG'; | ||
| public const SYMBOL = 'Æ’'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AustralianDollar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Australian Dollar'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'AUD'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class AzerbaijaniManat extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Azerbaijani Manat'; | ||
| public const SUBUNIT = 'Qəpik'; | ||
| public const ISO_CODE = 'AZN'; | ||
| public const SYMBOL = ''; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BahamianDollar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Bahamian Dollar'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'BSD'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BahrainiDinar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Bahraini Dinar'; | ||
| public const SUBUNIT = 'Fils'; | ||
| public const ISO_CODE = 'BHD'; | ||
| public const SYMBOL = 'ب.د'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 1000; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BangladeshiTaka extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Bangladeshi Taka'; | ||
| public const SUBUNIT = 'Paisa'; | ||
| public const ISO_CODE = 'BDT'; | ||
| public const SYMBOL = 'à§³'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BarbadianDollar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Barbadian Dollar'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'BBD'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BelarusianRuble extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Belarusian Ruble'; | ||
| public const SUBUNIT = 'Kapyeyka'; | ||
| public const ISO_CODE = 'BYR'; | ||
| public const SYMBOL = 'Br'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = false; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BelizeDollar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Belize Dollar'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'BZD'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
This file contains hidden or 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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PCF\ValueObject\Currency; | ||
|
|
||
| class BermudianDollar extends AbstractCurrency | ||
| { | ||
| public const FULL_NAME = 'Bermudian Dollar'; | ||
| public const SUBUNIT = 'Cent'; | ||
| public const ISO_CODE = 'BMD'; | ||
| public const SYMBOL = '$'; | ||
|
|
||
| protected const SUBUNIT_TO_UNIT = 100; | ||
| protected const SYMBOL_FIRST = true; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.