3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace texdc\cicerone; use InvalidArgumentException; /** * Provides encapsulation and validation of HTTP method values * * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html */ final class HttpMethod { /**#@+ * method constants * @var string */ const ANY = '*'; const GET = 'GET'; const HEAD = 'HEAD'; const POST = 'POST'; const PUT = 'PUT'; const DELETE = 'DELETE'; const OPTIONS = 'OPTIONS'; const TRACE = 'TRACE'; /**#@- */ /** @var string[] */ private static $allValues = [ self::ANY, self::GET, self::HEAD, self::POST, self::PUT, self::DELETE, self::OPTIONS, self::TRACE, ]; /** @var self[] */ private static $instances = []; /** @var string */ private $value; /** * @param string $aValue * @throws InvalidArgumentException */ public function HttpMethod($aValue) { if (!self::validate($aValue)) { throw new InvalidArgumentException("Invalid method [$aValue]"); } $this->value = self::sanitize($aValue); //static::$instances[$this->value] = $this; var_dump($this); } /** * @param string $aMethod * @param array $arguments * @return self */ public static function __callStatic($aMethod, $arguments = []) { if (!isset(static::$instances[$aMethod])) { $instance = new static($aMethod); $aMethod = $instance->value; } return static::$instances[$aMethod]; } /** * @param string $aValue * @return string */ public static function sanitize($aValue) { return trim(strtoupper($aValue)); } /** * @param string $aValue * @return bool */ public static function validate($aValue) { return in_array(self::sanitize($aValue), self::$allValues); } /** * @param string $aValue * @return bool */ public function hasValue($aValue) { return $this->value === (string) $aValue; } /** @return bool */ public function isAny() { return $this->hasValue(self::ANY); } /** @return bool */ public function isGet() { return $this->hasValue(self::GET) || $this->isAny(); } /** @return bool */ public function isHead() { return $this->hasValue(self::HEAD) || $this->isAny(); } /** @return bool */ public function isPost() { return $this->hasValue(self::POST) || $this->isAny(); } /** @return bool */ public function isPut() { return $this->hasValue(self::PUT) || $this->isAny(); } /** @return bool */ public function isDelete() { return $this->hasValue(self::DELETE) || $this->isAny(); } /** @return bool */ public function isOptions() { return $this->hasValue(self::OPTIONS) || $this->isAny(); } /** @return bool */ public function isTrace() { return $this->hasValue(self::TRACE) || $this->isAny(); } /** @return string */ public function __toString() { return $this->value; } } var_dump(new HttpMethod(HttpMethod::PUT));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.01216.62
8.3.50.0110.00821.97
8.3.40.0080.00818.67
8.3.30.0070.00718.92
8.3.20.0030.00520.16
8.3.10.0060.00321.85
8.3.00.0080.00019.26
8.2.180.0090.00916.63
8.2.170.0160.00722.96
8.2.160.0140.00020.35
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0000.00819.61
8.2.110.0030.00619.24
8.2.100.0060.00617.50
8.2.90.0000.00819.09
8.2.80.0040.00417.97
8.2.70.0000.00817.50
8.2.60.0110.00017.79
8.2.50.0030.00618.07
8.2.40.0000.00918.03
8.2.30.0040.00418.04
8.2.20.0000.00817.57
8.2.10.0080.00017.96
8.2.00.0050.00317.66
8.1.280.0070.01025.92
8.1.270.0040.00418.68
8.1.260.0000.00826.35
8.1.250.0140.00328.09
8.1.240.0030.00623.84
8.1.230.0090.00317.42
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0030.00617.38
8.1.190.0080.00017.09
8.1.180.0000.00818.10
8.1.170.0030.00620.44
8.1.160.0040.00421.98
8.1.150.0080.00018.71
8.1.140.0060.00317.39
8.1.130.0050.00317.73
8.1.120.0070.00317.37
8.1.110.0050.00217.34
8.1.100.0040.00417.46
8.1.90.0040.00417.47
8.1.80.0000.00817.46
8.1.70.0030.00317.38
8.1.60.0030.00517.41
8.1.50.0060.00317.39
8.1.40.0060.00617.53
8.1.30.0090.00017.53
8.1.20.0060.00317.60
8.1.10.0050.00217.35
8.1.00.0000.00817.45
8.0.300.0070.00018.77
8.0.290.0000.00816.63
8.0.280.0070.00018.46
8.0.270.0030.00317.18
8.0.260.0070.00017.29
8.0.250.0000.00716.88
8.0.240.0080.00016.84
8.0.230.0000.00716.93
8.0.220.0070.00016.78
8.0.210.0030.00316.73
8.0.200.0000.00616.84
8.0.190.0040.00416.88
8.0.180.0000.00716.86
8.0.170.0040.00416.82
8.0.160.0040.00416.79
8.0.150.0040.00416.84
8.0.140.0080.00016.81
8.0.130.0050.00213.34
8.0.120.0050.00316.71
8.0.110.0000.00716.85
8.0.100.0040.00416.81
8.0.90.0000.00716.84
8.0.80.0000.01616.87
8.0.70.0080.00016.79
8.0.60.0050.00316.82
8.0.50.0040.00416.87
8.0.30.0070.01216.96
8.0.20.0140.00617.40
8.0.10.0040.00416.75
8.0.00.0100.00816.76
7.4.330.0020.00215.05
7.4.320.0030.00316.51
7.4.300.0030.00316.36
7.4.290.0030.00316.42
7.4.280.0000.00816.50
7.4.270.0060.00316.43
7.4.260.0080.00016.51
7.4.250.0040.00416.48
7.4.240.0000.00916.40
7.4.230.0030.00316.39
7.4.220.0100.01016.50
7.4.210.0080.00916.55
7.4.200.0070.00016.54
7.4.160.0130.01016.32
7.4.150.0100.00717.40
7.4.140.0060.01117.86
7.4.130.0130.00816.42
7.4.120.0100.00716.38
7.4.110.0100.01016.45
7.4.100.0140.00316.16
7.4.90.0170.00616.42
7.4.80.0110.00719.39
7.4.70.0120.00616.43
7.4.60.0100.00716.35
7.4.50.0000.00816.24
7.4.40.0110.01116.36
7.4.30.0130.01016.45
7.4.00.0030.01014.96
7.3.330.0020.00213.29
7.3.320.0090.00513.22
7.3.310.0040.00416.19
7.3.300.0030.00316.23
7.3.290.0050.00216.09
7.3.280.0070.01016.24
7.3.270.0030.01317.40
7.3.260.0050.01516.39
7.3.250.0080.01016.37
7.3.240.0120.00916.20
7.3.230.0100.01016.39
7.3.210.0130.00616.27
7.3.200.0060.01019.39
7.3.190.0030.01316.32
7.3.180.0090.00616.14
7.3.170.0130.00316.38
7.3.160.0030.01316.28
7.2.330.0060.01316.64
7.2.320.0160.00616.31
7.2.310.0080.00816.59
7.2.300.0030.01516.33
7.2.290.0080.00816.58
7.2.00.0040.00819.54
7.1.100.0060.00918.11
7.1.70.0000.01117.13
7.1.60.0090.00919.50
7.1.50.0120.00916.60
7.1.00.0030.07722.54
7.0.200.0070.00016.70
7.0.140.0070.06022.13
7.0.60.0070.06019.97
7.0.50.0100.05717.91
7.0.40.0030.05020.23
7.0.30.0170.07720.17
7.0.20.0230.07020.05
7.0.10.0270.07320.01
7.0.00.0100.08720.07
5.6.280.0000.07721.09
5.6.210.0030.04020.71
5.6.200.0070.06318.26
5.6.190.0170.07720.63
5.6.180.0370.06720.46
5.6.170.0500.07020.55
5.6.160.0100.06320.47
5.6.150.0130.07318.17
5.6.140.0030.04018.25
5.6.130.0100.08018.14
5.6.120.0130.04721.01
5.6.110.0300.06021.14
5.6.100.0070.04021.11
5.6.90.0170.05721.03
5.6.80.0030.07020.39
5.5.350.0130.08020.43
5.5.340.0030.08017.99
5.5.330.0130.03720.42
5.5.320.0100.07020.41
5.5.310.0370.08020.30
5.5.300.0030.05018.04
5.5.290.0030.04018.04
5.5.280.0100.08320.93
5.5.270.0100.03720.87
5.5.260.0070.04020.82
5.5.250.0070.07020.50
5.5.240.0070.08320.07
5.4.450.0600.05019.55
5.4.440.0970.07019.50
5.4.430.0600.04319.31
5.4.420.0100.05319.58
5.4.410.0900.05319.19
5.4.400.0230.05718.78
5.4.390.0330.04718.77
5.4.380.0170.06018.61
5.4.370.0270.05318.50
5.4.360.0200.06018.73
5.4.350.0100.06718.78
5.4.340.0300.07018.75
5.4.320.0300.06718.54
5.4.310.0200.08018.55
5.4.300.0230.07718.74
5.4.290.0330.06318.61
5.4.280.0300.07018.71
5.4.270.0330.07318.77
5.4.260.0200.08018.48
5.4.250.0430.06318.85
5.4.240.0300.07718.77
5.4.230.0370.06718.67
5.4.220.0130.06318.74
5.4.210.0330.04318.79
5.4.200.0300.04716.71
5.4.190.0270.05018.45
5.4.180.0230.05318.59
5.4.170.0330.04718.59
5.4.160.0200.05318.83
5.4.150.0200.05318.52
5.4.140.0130.05716.32
5.4.130.0270.05016.36
5.4.120.0200.05716.47
5.4.110.0430.05716.32
5.4.100.0300.06316.35
5.4.90.0270.07316.45
5.4.80.0400.06716.24
5.4.70.0270.07316.43
5.4.60.0270.07316.20
5.4.50.0300.06316.19
5.4.40.0300.07016.29
5.4.30.0330.07016.32
5.4.20.0270.07016.37
5.4.10.0270.06716.45
5.4.00.0270.06715.70
5.3.290.0470.06714.81
5.3.280.0330.07014.63
5.3.270.0400.06014.85
5.3.260.0300.06314.83
5.3.250.0300.05714.61
5.3.240.0300.06014.60
5.3.230.0200.05714.64
5.3.220.0330.05014.67
5.3.210.0370.04714.69
5.3.200.0330.05014.61
5.3.190.0330.05314.69
5.3.180.0400.05314.61
5.3.170.0330.04714.61
5.3.160.0430.05714.56
5.3.150.0370.07314.78
5.3.140.0430.07014.69
5.3.130.0370.08014.53
5.3.120.0330.04714.59
5.3.110.0230.06314.59
5.3.100.0300.05014.27
5.3.90.0400.04014.22
5.3.80.0230.05314.11
5.3.70.0200.06014.12
5.3.60.0270.04314.11
5.3.50.0300.04714.11
5.3.40.0130.06713.96
5.3.30.0330.04713.94
5.3.20.0230.05013.81
5.3.10.0200.05313.70
5.3.00.0230.05313.68
5.2.170.0270.04011.10
5.2.160.0230.04311.13
5.2.150.0130.05311.11
5.2.140.0330.05011.30
5.2.130.0230.05311.14
5.2.120.0300.05011.07
5.2.110.0230.05711.16
5.2.100.0400.03711.24
5.2.90.0270.03711.16
5.2.80.0230.04011.06
5.2.70.0270.05011.09
5.2.60.0400.04711.10
5.2.50.0300.05710.99
5.2.40.0330.03710.95
5.2.30.0230.07010.90
5.2.20.0230.05310.96
5.2.10.0100.05010.86
5.2.00.0270.03710.73
5.1.60.0230.0339.97
5.1.50.0230.04010.01
5.1.40.0230.0339.94
5.1.30.0330.04010.31
5.1.20.0200.04310.39
5.1.10.0100.04310.09
5.1.00.0230.03710.09
5.0.50.0130.0408.62
5.0.40.0030.0478.45
5.0.30.0100.0608.27
5.0.20.0130.0338.19
5.0.10.0130.0308.27
5.0.00.0130.0408.19
4.4.90.0170.0137.64
4.4.80.0100.0207.64
4.4.70.0100.0207.64
4.4.60.0100.0237.64
4.4.50.0100.0237.64
4.4.40.0130.0307.64
4.4.30.0030.0277.64
4.4.20.0130.0277.64
4.4.10.0100.0307.64
4.4.00.0130.0377.64
4.3.110.0100.0237.64
4.3.100.0070.0237.64
4.3.90.0070.0237.64
4.3.80.0030.0377.64
4.3.70.0030.0277.64
4.3.60.0130.0177.64
4.3.50.0000.0307.64
4.3.40.0130.0307.64
4.3.30.0030.0237.64
4.3.20.0070.0277.64
4.3.10.0100.0237.64
4.3.00.0070.0239.29

preferences:
44.76 ms | 401 KiB | 5 Q