<?php
final class CommandId
{
private $name;
private $time;
private $hash;
public function __construct($name, $time = null, $hash = null)
{
$this->time = (float) ($time ?: microtime(true));
$this->name = trim($name);
$this->hash = $hash ?: hash('crc32', rand(0, $this->time));
if (empty($this->name)) {
throw new DomainException('Name must not be empty');
}
}
public static function fromString($idString)
{
$parts = explode('_', $idString);
if (count($parts) != 3) {
throw new DomainException("Unexpected format [$idString]");
}
return new static($parts[0], $parts[1], $parts[2]);
}
public function name()
{
return $this->name;
}
public function time()
{
return $this->time;
}
public function equals(self $other)
{
return ($this->name == $other->name
&& $this->time == $other->time
&& $this->hash == $other->hash
);
}
public function __toString()
{
return implode('_', [$this->name, $this->time, $this->hash]);
}
}
$one = new CommandId('foo');
var_dump((string) $one, $one->equals(CommandId::fromString((string) $one)));
- Output for 7.2.0
- string(28) "foo_1392277736.0041_ab2c799a"
bool(false)
- Output for 7.1.7
- string(28) "foo_1392277736.0033_5f602996"
bool(false)
- Output for 7.1.6
- string(28) "foo_1392277736.0127_a40815c0"
bool(false)
- Output for 7.1.5
- string(26) "foo_1392277736.01_9c143efe"
bool(false)
- Output for 7.1.0
- string(28) "foo_1392277736.0055_4b2e837b"
bool(false)
- Output for 7.0.20
- string(28) "foo_1392277736.0025_255a5938"
bool(false)
- Output for 7.0.14
- string(28) "foo_1392277736.0037_8157bc97"
bool(false)
- Output for 7.0.6
- string(28) "foo_1462260467.6051_c6ab6d3f"
bool(false)
- Output for 7.0.5
- string(28) "foo_1459628434.3164_349d9189"
bool(false)
- Output for 7.0.4
- string(28) "foo_1457596222.8956_cfae05b1"
bool(false)
- Output for 7.0.3
- string(28) "foo_1458289641.8513_40ba96c2"
bool(false)
- Output for 7.0.2
- string(28) "foo_1458656466.6369_cc724358"
bool(false)
- Output for 7.0.1
- string(28) "foo_1458760089.6744_6eda81b3"
bool(false)
- Output for 7.0.0
- string(26) "foo_1459024872.87_443435c1"
bool(false)
- Output for 5.6.28
- string(28) "foo_1392277736.0046_0fe0ed4e"
bool(false)
- Output for 5.6.21
- string(28) "foo_1462157355.8417_419b95d7"
bool(false)
- Output for 5.6.20
- string(28) "foo_1460229420.5125_a0ba1488"
bool(false)
- Output for 5.6.19
- string(28) "foo_1457366352.6645_7b805bf8"
bool(false)
- Output for 5.6.18
- string(28) "foo_1457999535.3018_b95ae904"
bool(false)
- Output for 5.6.17
- string(28) "foo_1458391402.5511_ed1f0392"
bool(false)
- Output for 5.6.16
- string(28) "foo_1459113996.7362_4d71109b"
bool(false)
- Output for 5.6.15
- string(28) "foo_1459203926.1609_b529e1f4"
bool(false)
- Output for 5.6.14
- string(28) "foo_1459558368.2191_f70a7d8d"
bool(false)
- Output for 5.6.13
- string(28) "foo_1460695628.3616_d7fb1287"
bool(false)
- Output for 5.6.12
- string(28) "foo_1461090644.8077_865b6e99"
bool(false)
- Output for 5.6.11
- string(28) "foo_1461375304.1966_aeaa6ba0"
bool(false)
- Output for 5.6.10
- string(28) "foo_1461554305.9876_a039c4d1"
bool(false)
- Output for 5.6.9
- string(28) "foo_1461744985.1449_6780382a"
bool(false)
- Output for 5.6.8
- string(28) "foo_1461946863.1594_2d8ffd4d"
bool(false)
- Output for 5.5.35
- string(28) "foo_1463898785.7707_cc06745d"
bool(false)
- Output for 5.5.34
- string(28) "foo_1460324257.5453_1320ef93"
bool(false)
- Output for 5.5.33
- string(28) "foo_1457463315.7367_6cb2c712"
bool(false)
- Output for 5.5.32
- string(28) "foo_1458178561.4532_ce6af102"
bool(false)
- Output for 5.5.31
- string(28) "foo_1458487755.2111_f220fdab"
bool(false)
- Output for 5.5.30
- string(27) "foo_1459470444.367_47094960"
bool(false)
- Output for 5.5.29
- string(28) "foo_1460832735.8463_dce11249"
bool(false)
- Output for 5.5.28
- string(28) "foo_1461188165.7098_d77418eb"
bool(false)
- Output for 5.5.27
- string(28) "foo_1461283540.9012_fada0015"
bool(false)
- Output for 5.5.26
- string(28) "foo_1461649537.8987_8ffa0f70"
bool(false)
- Output for 5.5.25
- string(28) "foo_1461845006.7124_25c05f23"
bool(false)
- Output for 5.5.24
- string(28) "foo_1464030349.8834_0e278c60"
bool(false)
- Output for 5.4.45
- string(27) "foo_1442526225.245_6193bfd7"
bool(false)
- Output for 5.4.44
- string(28) "foo_1440770924.4963_1649089d"
bool(false)
- Output for 5.4.43
- string(28) "foo_1440770921.3876_122892be"
bool(false)
- Output for 5.4.42
- string(28) "foo_1440770920.1214_90b3348b"
bool(false)
- Output for 5.4.41
- string(27) "foo_1440770917.992_42df415a"
bool(false)
- Output for 5.4.40
- string(28) "foo_1440770915.1273_942d71a9"
bool(false)
- Output for 5.4.39
- string(28) "foo_1440770914.7217_8335654a"
bool(false)
- Output for 5.4.38
- string(28) "foo_1425280142.6224_714440f8"
bool(false)
- Output for 5.4.37
- string(28) "foo_1423359930.5611_33c7fa1f"
bool(false)
- Output for 5.4.36
- string(28) "foo_1423359930.2081_00f4a912"
bool(false)
- Output for 5.4.35
- string(28) "foo_1417713153.0755_edb59b4a"
bool(false)
- Output for 5.4.34
- string(28) "foo_1417713152.7715_e4783bab"
bool(false)
- Output for 5.4.32
- string(28) "foo_1409986445.3427_0d9a6b6e"
bool(false)
- Output for 5.4.31
- string(28) "foo_1409986439.5083_7cf3cbac"
bool(false)
- Output for 5.4.30
- string(28) "foo_1409986434.0123_9c547dcf"
bool(false)
- Output for 5.4.29
- string(28) "foo_1409986433.5148_415c61c6"
bool(false)
- Output for 5.4.28
- string(28) "foo_1409986433.0038_28d4827b"
bool(false)
- Output for 5.4.27
- string(28) "foo_1409986441.9101_f1c8a540"
bool(false)
- Output for 5.4.26
- string(28) "foo_1409986441.3159_d5bcbddd"
bool(false)
- Output for 5.4.25
- string(28) "foo_1392277736.0064_ad3281b6"
bool(false)
- Output for 5.4.24
- string(28) "foo_1392277736.0045_8793436b"
bool(false)
- Output for 5.4.23
- string(27) "foo_1392277736.005_7c074cf1"
bool(false)
- Output for 5.4.22
- string(28) "foo_1392277736.0061_7b100455"
bool(false)
- Output for 5.4.21
- string(28) "foo_1392277736.0073_e937825a"
bool(false)
- Output for 5.4.20
- string(28) "foo_1392277736.0047_f1ee873c"
bool(false)
- Output for 5.4.19
- string(28) "foo_1392277736.0042_91957fd7"
bool(false)
- Output for 5.4.18
- string(28) "foo_1392277736.0082_f328af2f"
bool(false)
- Output for 5.4.17
- string(28) "foo_1392277736.0072_8f8519b5"
bool(false)
- Output for 5.4.16
- string(28) "foo_1392277736.0047_6c9c8a12"
bool(false)
- Output for 5.4.15
- string(28) "foo_1392277736.0051_558f8c9b"
bool(false)
- Output for 5.4.14
- string(28) "foo_1392277736.0032_9a1e3ca6"
bool(false)
- Output for 5.4.13
- string(28) "foo_1392277736.0041_c5d81563"
bool(false)
- Output for 5.4.12
- string(28) "foo_1392277736.0037_555fd42c"
bool(false)
- Output for 5.4.11
- string(28) "foo_1392277736.0028_850540d0"
bool(false)
- Output for 5.4.10
- string(28) "foo_1392277736.0027_f941a0c3"
bool(false)
- Output for 5.4.9
- string(28) "foo_1392277736.0023_b9706844"
bool(false)
- Output for 5.4.8
- string(28) "foo_1392277736.0028_03063c40"
bool(false)
- Output for 5.4.7
- string(28) "foo_1392277736.0026_b171de94"
bool(false)
- Output for 5.4.6
- string(28) "foo_1392277736.0027_ea5b861a"
bool(false)
- Output for 5.4.5
- string(28) "foo_1392277736.0024_e8a43a5d"
bool(false)
- Output for 5.4.4
- string(28) "foo_1392277736.0038_d92d9f5c"
bool(false)
- Output for 5.4.3
- string(27) "foo_1392277736.003_1d2202a1"
bool(false)
- Output for 5.4.2
- string(28) "foo_1392277736.0022_6daa1a18"
bool(false)
- Output for 5.4.1
- string(28) "foo_1392277736.0034_188cbb57"
bool(false)
- Output for 5.4.0
- string(28) "foo_1392277736.0029_8321ac21"
bool(false)
- Output for 5.3.0 - 5.3.29
- Parse error: syntax error, unexpected '[' in /in/i2SKp on line 49
Process exited with code 255. - Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
- Parse error: syntax error, unexpected ':' in /in/i2SKp on line 11
Process exited with code 255. - Output for 5.0.0 - 5.0.5
- Parse error: parse error, unexpected ':' in /in/i2SKp on line 11
Process exited with code 255. - Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected T_CLASS in /in/i2SKp on line 3
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected T_CLASS in /in/i2SKp on line 3
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/i2SKp on line 3
Process exited with code 255.
preferences:
165.25 ms | 401 KiB | 174 Q