This repository has been archived by the owner on Nov 9, 2021. It is now read-only.
generated from renoki-co/laravel-package-skeleton
-
-
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.
[5.x] Metered prices within Feature (#32)
Co-authored-by: rennokki <[email protected]>
- Loading branch information
Showing
10 changed files
with
584 additions
and
251 deletions.
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
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
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
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
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,90 @@ | ||
<?php | ||
|
||
namespace RenokiCo\CashierRegister; | ||
|
||
class MeteredFeature extends Feature | ||
{ | ||
/** | ||
* The metered price ID, in case | ||
* the feature has a quota for metered price. | ||
* | ||
* @var string|int|null | ||
*/ | ||
protected $meteredId; | ||
|
||
/** | ||
* The metered price per unit, in case | ||
* the feature has a quota for metered price. | ||
* | ||
* @var float | ||
*/ | ||
protected $meteredPrice = 0.00; | ||
|
||
/** | ||
* The metered unit name. | ||
* | ||
* @var string | ||
*/ | ||
protected $meteredUnitName; | ||
|
||
/** | ||
* Set the metered price. | ||
* | ||
* @param string|int $id | ||
* @param float $price | ||
* @param string|null $unitName | ||
* @return self | ||
*/ | ||
public function meteredPrice($id, float $price, string $unitName = null) | ||
{ | ||
$this->meteredId = $id; | ||
$this->meteredPrice = $price; | ||
$this->meteredUnitName = $unitName; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get the metered price ID. | ||
* | ||
* @return string|int|null | ||
*/ | ||
public function getMeteredId() | ||
{ | ||
return $this->meteredId; | ||
} | ||
|
||
/** | ||
* Get the metered price. | ||
* | ||
* @return float | ||
*/ | ||
public function getMeteredPrice(): float | ||
{ | ||
return $this->meteredPrice; | ||
} | ||
|
||
/** | ||
* Get the metered unit name. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getMeteredUnitName() | ||
{ | ||
return $this->meteredUnitName; | ||
} | ||
|
||
/** | ||
* Get the instance as an array. | ||
* | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
return array_merge(parent::toArray(), [ | ||
'metered_id' => $this->getMeteredId(), | ||
'metered_price' => $this->getMeteredPrice(), | ||
'metered_unit_name' => $this->getMeteredUnitName(), | ||
]); | ||
} | ||
} |
Oops, something went wrong.