One Hat Cyber Team
Your IP:
216.73.216.48
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
proc
/
self
/
root
/
home
/
fluxyjvi
/
www
/
assets
/
images
/
Edit File:
Currencies.tar
CachedCurrencies.php 0000644 00000004304 15107411011 0010437 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use ArrayIterator; use Cache\TagInterop\TaggableCacheItemInterface; use CallbackFilterIterator; use Money\Currencies; use Money\Currency; use Psr\Cache\CacheItemPoolInterface; use Traversable; use function iterator_to_array; /** * Cache the result of currency checking. */ final class CachedCurrencies implements Currencies { private Currencies $currencies; private CacheItemPoolInterface $pool; public function __construct(Currencies $currencies, CacheItemPoolInterface $pool) { $this->currencies = $currencies; $this->pool = $pool; } public function contains(Currency $currency): bool { $item = $this->pool->getItem('currency|availability|' . $currency->getCode()); if ($item->isHit() === false) { $item->set($this->currencies->contains($currency)); if ($item instanceof TaggableCacheItemInterface) { $item->setTags(['currency.availability']); } $this->pool->save($item); } return (bool) $item->get(); } public function subunitFor(Currency $currency): int { $item = $this->pool->getItem('currency|subunit|' . $currency->getCode()); if ($item->isHit() === false) { $item->set($this->currencies->subunitFor($currency)); if ($item instanceof TaggableCacheItemInterface) { $item->setTags(['currency.subunit']); } $this->pool->save($item); } return (int) $item->get(); } /** {@inheritDoc} */ public function getIterator(): Traversable { return new CallbackFilterIterator( new ArrayIterator(iterator_to_array($this->currencies->getIterator())), function (Currency $currency): bool { $item = $this->pool->getItem('currency|availability|' . $currency->getCode()); $item->set(true); if ($item instanceof TaggableCacheItemInterface) { $item->setTags(['currency.availability']); } $this->pool->save($item); return true; } ); } } CurrencyList.php 0000644 00000002571 15107411011 0007677 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use ArrayIterator; use Money\Currencies; use Money\Currency; use Money\Exception\UnknownCurrencyException; use Traversable; use function array_keys; use function array_map; /** * A list of custom currencies. */ final class CurrencyList implements Currencies { /** * Map of currencies and their sub-units indexed by code. * * @psalm-var array<non-empty-string, int> */ private array $currencies; /** @psalm-param array<non-empty-string, positive-int|0> $currencies */ public function __construct(array $currencies) { $this->currencies = $currencies; } public function contains(Currency $currency): bool { return isset($this->currencies[$currency->getCode()]); } public function subunitFor(Currency $currency): int { if (! $this->contains($currency)) { throw new UnknownCurrencyException('Cannot find currency ' . $currency->getCode()); } return $this->currencies[$currency->getCode()]; } /** {@inheritDoc} */ public function getIterator(): Traversable { return new ArrayIterator( array_map( static function ($code) { return new Currency($code); }, array_keys($this->currencies) ) ); } } BitcoinCurrencies.php 0000644 00000001544 15107411011 0010662 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use ArrayIterator; use Money\Currencies; use Money\Currency; use Money\Exception\UnknownCurrencyException; use Traversable; final class BitcoinCurrencies implements Currencies { public const CODE = 'XBT'; public const SYMBOL = "\xC9\x83"; public function contains(Currency $currency): bool { return $currency->getCode() === self::CODE; } public function subunitFor(Currency $currency): int { if ($currency->getCode() !== self::CODE) { throw new UnknownCurrencyException($currency->getCode() . ' is not bitcoin and is not supported by this currency repository'); } return 8; } /** {@inheritDoc} */ public function getIterator(): Traversable { return new ArrayIterator([new Currency(self::CODE)]); } } AggregateCurrencies.php 0000644 00000003134 15107411011 0011156 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use AppendIterator; use Money\Currencies; use Money\Currency; use Money\Exception\UnknownCurrencyException; use Traversable; /** * Aggregates several currency repositories. */ final class AggregateCurrencies implements Currencies { /** @var Currencies[] */ private array $currencies; /** * @param Currencies[] $currencies */ public function __construct(array $currencies) { $this->currencies = $currencies; } public function contains(Currency $currency): bool { foreach ($this->currencies as $currencies) { if ($currencies->contains($currency)) { return true; } } return false; } public function subunitFor(Currency $currency): int { foreach ($this->currencies as $currencies) { if ($currencies->contains($currency)) { return $currencies->subunitFor($currency); } } throw new UnknownCurrencyException('Cannot find currency ' . $currency->getCode()); } /** {@inheritDoc} */ public function getIterator(): Traversable { /** @psalm-var AppendIterator&Traversable<int|string, Currency> $iterator */ $iterator = new AppendIterator(); foreach ($this->currencies as $currencies) { $currencyIterator = $currencies->getIterator(); /** @psalm-var AppendIterator&Traversable<int|string, Currency> $currencyIterator */ $iterator->append($currencyIterator); } return $iterator; } } ISOCurrencies.php 0000644 00000006171 15107411011 0007726 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use ArrayIterator; use Money\Currencies; use Money\Currency; use Money\Exception\UnknownCurrencyException; use RuntimeException; use Traversable; use function array_keys; use function array_map; use function is_file; /** * List of supported ISO 4217 currency codes and names. */ final class ISOCurrencies implements Currencies { /** * Map of known currencies indexed by code. * * @psalm-var non-empty-array<non-empty-string, array{ * alphabeticCode: non-empty-string, * currency: non-empty-string, * minorUnit: positive-int|0, * numericCode: positive-int * }>|null */ private static ?array $currencies = null; public function contains(Currency $currency): bool { return isset($this->getCurrencies()[$currency->getCode()]); } public function subunitFor(Currency $currency): int { if (! $this->contains($currency)) { throw new UnknownCurrencyException('Cannot find ISO currency ' . $currency->getCode()); } return $this->getCurrencies()[$currency->getCode()]['minorUnit']; } /** * Returns the numeric code for a currency. * * @throws UnknownCurrencyException If currency is not available in the current context. */ public function numericCodeFor(Currency $currency): int { if (! $this->contains($currency)) { throw new UnknownCurrencyException('Cannot find ISO currency ' . $currency->getCode()); } return $this->getCurrencies()[$currency->getCode()]['numericCode']; } /** * @psalm-return Traversable<int, Currency> */ public function getIterator(): Traversable { return new ArrayIterator( array_map( static function ($code) { return new Currency($code); }, array_keys($this->getCurrencies()) ) ); } /** * Returns a map of known currencies indexed by code. * * @psalm-return non-empty-array<non-empty-string, array{ * alphabeticCode: non-empty-string, * currency: non-empty-string, * minorUnit: positive-int|0, * numericCode: positive-int * }> */ private function getCurrencies(): array { if (self::$currencies === null) { self::$currencies = $this->loadCurrencies(); } return self::$currencies; } /** * @psalm-return non-empty-array<non-empty-string, array{ * alphabeticCode: non-empty-string, * currency: non-empty-string, * minorUnit: positive-int|0, * numericCode: positive-int * }> * * @psalm-suppress MoreSpecificReturnType do not specify all keys and values */ private function loadCurrencies(): array { $file = __DIR__ . '/../../resources/currency.php'; if (is_file($file)) { /** @psalm-suppress LessSpecificReturnStatement */ return require $file; } throw new RuntimeException('Failed to load currency ISO codes.'); } } CryptoCurrencies.php 0000644 00000004702 15107411011 0010552 0 ustar 00 <?php declare(strict_types=1); namespace Money\Currencies; use ArrayIterator; use Money\Currencies; use Money\Currency; use Money\Exception\UnknownCurrencyException; use RuntimeException; use Traversable; use function array_keys; use function array_map; use function is_file; /** * List of supported Crypto Currencies codes and names using Binance as resource. */ final class CryptoCurrencies implements Currencies { /** * Map of known currencies indexed by code. * * @psalm-var non-empty-array<non-empty-string, array{ * symbol: non-empty-string, * minorUnit: positive-int|0 * }>|null */ private static ?array $currencies = null; public function contains(Currency $currency): bool { return isset($this->getCurrencies()[$currency->getCode()]); } public function subunitFor(Currency $currency): int { if (! $this->contains($currency)) { throw new UnknownCurrencyException('Cannot find ISO currency ' . $currency->getCode()); } return $this->getCurrencies()[$currency->getCode()]['minorUnit']; } /** * @psalm-return Traversable<int, Currency> */ public function getIterator(): Traversable { return new ArrayIterator( array_map( static function ($code) { return new Currency($code); }, array_keys($this->getCurrencies()) ) ); } /** * Returns a map of known currencies indexed by code. * * @psalm-return non-empty-array<non-empty-string, array{ * symbol: non-empty-string, * minorUnit: positive-int|0 * }> */ private function getCurrencies(): array { if (self::$currencies === null) { self::$currencies = $this->loadCurrencies(); } return self::$currencies; } /** * @psalm-return non-empty-array<non-empty-string, array{ * symbol: non-empty-string, * minorUnit: positive-int|0 * }> * * @psalm-suppress MoreSpecificReturnType do not specify all keys and values */ private function loadCurrencies(): array { $file = __DIR__ . '/../../resources/binance.php'; if (is_file($file)) { /** @psalm-suppress LessSpecificReturnStatement */ return require $file; } throw new RuntimeException('Failed to load currency ISO codes.'); } }
Simpan