This repository has been archived on 2023-10-21. You can view files and clone it, but cannot push or open issues or pull requests.
patchouli/src/Dummy/DummyPackage.php
2020-12-27 04:10:44 +00:00

91 lines
3.2 KiB
PHP

<?php
namespace Patchouli\Dummy;
use Patchouli\IPackage;
use Patchouli\Version;
class DummyPackage implements IPackage, \JsonSerializable {
public function getId(): string {
return 'package-id';
}
public function getName(): string {
return 'Human Readable Name';
}
public function getVersion(): Version {
return new Version;
}
public function getDependencies(): array {
return [];
}
public function fwifSerialize(): array {
$data = [
'null' => null,
'zero' => 0,
'u8' => 0x42,
'u16' => 0x4344,
'u24' => 0x454647,
'u32' => 0x58596061,
'u40' => 0x6263646566,
'u48' => 0x676869707172,
'u56' => 0x73747576777879,
'u64' => 0x7481828384858687,
'neg32' => -12345678,
'neg64' => -1234567890987654,
'float' => 12345.6789,
'float2' => 8.0,
'floatNeg' => -12345.6789,
'floatPi' => M_PI,
'floatE' => M_E,
'floatLog2E' => M_LOG2E,
'floatLog10E' => M_LOG10E,
'floatLn2' => M_LN2,
'floatLn10' => M_LN10,
'floatPi2' => M_PI_2,
'floatPi4' => M_PI_4,
'floatM1Pi' => M_1_PI,
'floatM2Pi' => M_2_PI,
'floatSqrtPi' => M_SQRTPI,
'float2SqrtPi' => M_2_SQRTPI,
'floatSqrt2' => M_SQRT2,
'floatSqrt3' => M_SQRT3,
'floatSqrt12' => M_SQRT1_2,
'floatLnPi' => M_LNPI,
'floatEuler' => M_EULER,
//'floatNaN' => NAN,
//'floatInf' => INF,
//'floatNegInf' => -INF,
'floatZero' => 0.0,
'floatNegZero' => -0.0,
'invalid' => "\xFF\x25\x25\x02\xFF蠕。蝮F鄒守清\xFF\xFF\xFF",
'datetime' => new \DateTime('2013-01-27 23:14:44 CET'),
'datetimeNegative' => new \DateTime('-2013-01-27 23:14:44 CET'),
'datetimeNow' => new \DateTime(),
'period' => (new \DateTime())->diff(new \DateTime('2013-01-27 23:14:44 CET')),
'periodNegative' => (new \DateTime('2013-01-27 23:14:44 CET'))->diff(new \DateTime()),
'periodZero' => (new \DateTime())->diff(new \DateTime()),
'array' => ['e', 'a', 0x55],
'object' => new \stdClass,
'misaka' => '御坂 美琴',
'id' => $this->getId(),
'name' => $this->getName(),
'version' => $this->getVersion(),
'deps' => [],
];
foreach($this->getDependencies() as $dependency)
$data['deps'][] = $dependency->getName();
return $data;
}
public function jsonSerialize() {
$serial = $this->fwifSerialize();
$serial['datetime'] = $serial['datetime']->format(\DateTimeInterface::ATOM);
$serial['datetimeNegative'] = $serial['datetimeNegative']->format(\DateTimeInterface::ATOM);
$serial['datetimeNow'] = $serial['datetimeNow']->format(\DateTimeInterface::ATOM);
return $serial;
}
}