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 */ private function __construct($aValue) { if (!self::validate($aValue)) { throw new InvalidArgumentException("Invalid method [$aValue]"); } $this->value = self::sanitize($aValue); self::$instances[$this->value] = $this; } /** * @param string $aMethod * @param array $arguments * @return self */ public static function __callStatic($aMethod, $arguments = []) { if (self::sanitize($aMethod) === 'ANY') { $aMethod = self::ANY; } if (!isset(self::$instances[$aMethod])) { $instance = new static($aMethod); $aMethod = $instance->value; } return self::$instances[$aMethod]; } /** * @param string $aValue * @return string */ private static function sanitize($aValue) { return strtoupper(trim($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(HttpMethod::ANY());

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.0120.00616.88
8.3.50.0070.00718.24
8.3.40.0100.00619.02
8.3.30.0140.00019.24
8.3.20.0040.00420.14
8.3.10.0040.00422.08
8.3.00.0040.01119.38
8.2.180.0130.00718.41
8.2.170.0120.00622.96
8.2.160.0100.00320.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0040.00419.66
8.2.110.0030.00522.21
8.2.100.0110.00017.84
8.2.90.0000.00919.20
8.2.80.0050.00317.97
8.2.70.0100.00017.50
8.2.60.0050.00318.04
8.2.50.0000.00818.07
8.2.40.0030.00619.88
8.2.30.0040.00418.17
8.2.20.0050.00317.67
8.2.10.0000.00818.11
8.2.00.0000.00817.77
8.1.280.0070.01125.92
8.1.270.0030.00620.73
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.01121.79
8.1.230.0040.00820.87
8.1.220.0030.00618.61
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0030.00617.25
8.1.180.0040.00418.10
8.1.170.0080.00020.43
8.1.160.0040.00422.05
8.1.150.0000.00718.84
8.1.140.0040.00417.39
8.1.130.0000.00717.93
8.1.120.0040.00817.47
8.1.110.0020.00517.46
8.1.100.0030.00517.51
8.1.90.0000.00817.45
8.1.80.0000.00717.51
8.1.70.0030.00317.50
8.1.60.0000.00817.64
8.1.50.0070.00417.46
8.1.40.0070.00417.42
8.1.30.0030.00617.59
8.1.20.0080.00017.75
8.1.10.0040.00417.58
8.1.00.0040.00417.44
8.0.300.0050.00518.77
8.0.290.0000.00816.75
8.0.280.0030.00318.40
8.0.270.0000.00717.21
8.0.260.0030.00317.21
8.0.250.0000.00716.89
8.0.240.0060.00316.99
8.0.230.0070.00016.89
8.0.220.0030.00316.93
8.0.210.0000.00716.89
8.0.200.0000.00816.91
8.0.190.0030.00316.89
8.0.180.0040.00416.84
8.0.170.0080.00016.92
8.0.160.0060.00316.96
8.0.150.0040.00416.77
8.0.140.0040.00416.97
8.0.130.0070.00013.39
8.0.120.0030.00616.87
8.0.110.0040.00417.00
8.0.100.0000.00716.82
8.0.90.0000.00816.88
8.0.80.0060.00916.92
8.0.70.0040.00416.88
8.0.60.0030.00516.91
8.0.50.0000.00816.71
8.0.30.0070.00517.18
8.0.20.0150.02417.40
8.0.10.0070.00016.95
8.0.00.0120.00616.74
7.4.330.0050.00015.08
7.4.320.0030.00316.64
7.4.300.0030.00316.65
7.4.290.0000.00716.61
7.4.280.0080.00016.54
7.4.270.0000.00816.44
7.4.260.0070.00016.63
7.4.250.0070.00016.60
7.4.240.0020.00716.54
7.4.230.0040.00416.67
7.4.220.0120.01316.50
7.4.210.0000.01516.55
7.4.200.0000.00716.58
7.4.160.0040.01116.30
7.4.150.0040.01517.40
7.4.140.0150.00317.86
7.4.130.0090.00916.56
7.4.120.0100.00816.55
7.4.110.0030.01516.64
7.4.100.0190.00816.54
7.4.90.0070.01016.42
7.4.80.0080.00919.39
7.4.70.0120.00616.64
7.4.60.0060.00916.71
7.4.50.0040.00416.45
7.4.40.0120.00916.55
7.4.30.0140.00616.23
7.4.10.0070.01014.90
7.4.00.0040.01114.92
7.3.330.0050.00013.28
7.3.320.0160.00013.42
7.3.310.0000.00716.42
7.3.300.0030.00316.38
7.3.290.0050.00216.30
7.3.280.0080.01116.43
7.3.270.0090.00917.40
7.3.260.0070.01716.68
7.3.250.0080.01316.36
7.3.240.0050.01116.48
7.3.230.0040.01416.39
7.3.210.0070.01116.78
7.3.200.0070.01019.39
7.3.190.0060.01016.48
7.3.180.0090.00616.54
7.3.170.0000.01616.38
7.3.160.0160.00316.41
7.3.130.0070.01014.93
7.3.120.0030.01414.98
7.3.110.0070.01015.00
7.3.100.0090.00614.62
7.3.90.0060.00914.77
7.3.80.0000.01114.91
7.3.70.0030.00714.63
7.3.60.0040.00714.87
7.3.50.0080.00814.91
7.3.40.0060.00314.88
7.3.30.0070.01014.96
7.3.20.0060.01016.78
7.3.10.0090.00816.48
7.3.00.0070.01016.53
7.2.330.0050.01916.79
7.2.320.0100.01016.86
7.2.310.0100.00616.71
7.2.300.0030.01316.87
7.2.290.0130.00316.96
7.2.260.0060.00914.86
7.2.250.0000.01915.32
7.2.240.0060.00615.29
7.2.230.0160.00014.77
7.2.220.0070.01015.13
7.2.210.0090.00615.31
7.2.200.0030.01315.16
7.2.190.0060.00915.16
7.2.180.0070.00714.92
7.2.170.0040.00815.14
7.2.160.0060.01015.05
7.2.150.0140.00316.72
7.2.140.0080.00417.12
7.2.130.0070.00716.69
7.2.120.0100.00416.71
7.2.110.0110.00816.91
7.2.100.0060.01016.78
7.2.90.0070.01116.88
7.2.80.0080.00916.75
7.2.70.0080.01016.84
7.2.60.0090.00616.89
7.2.50.0100.00516.84
7.2.40.0070.00916.72
7.2.30.0070.01016.91
7.2.20.0100.00616.80
7.2.10.0090.00516.87
7.2.00.0060.00717.42
7.1.330.0040.00815.86
7.1.320.0030.01016.02
7.1.310.0130.00316.02
7.1.300.0060.00615.79
7.1.290.0070.00315.59
7.1.280.0070.00715.83
7.1.270.0070.00715.69
7.1.260.0060.00615.84
7.1.250.0110.00315.54
7.1.240.0110.00415.68
7.1.230.0060.00615.63
7.1.220.0060.00915.63
7.1.210.0030.01215.75
7.1.200.0020.01115.86
7.1.190.0090.00615.47
7.1.180.0060.00315.80
7.1.170.0060.00615.79
7.1.160.0040.01415.83
7.1.150.0060.00315.46
7.1.140.0000.01416.02
7.1.130.0100.00315.85
7.1.120.0140.00015.91
7.1.110.0070.01015.88
7.1.100.0080.00516.92
7.1.90.0070.01015.85
7.1.80.0060.00915.66
7.1.70.0080.00716.48
7.1.60.0090.01117.60
7.1.50.0070.00716.23
7.1.40.0070.00715.88
7.1.30.0120.00316.01
7.1.20.0060.00615.51
7.1.10.0070.01015.84
7.1.00.0080.04019.20
7.0.330.0030.00715.53
7.0.320.0140.00015.51
7.0.310.0060.00315.52
7.0.300.0070.00715.32
7.0.290.0060.01315.52
7.0.280.0100.00315.18
7.0.270.0040.00815.38
7.0.260.0040.01115.60
7.0.250.0060.00615.41
7.0.240.0030.01015.33
7.0.230.0030.01315.17
7.0.220.0070.00715.29
7.0.210.0060.00615.46
7.0.200.0020.00816.07
7.0.190.0070.00715.47
7.0.180.0100.00615.21
7.0.170.0040.00915.38
7.0.160.0060.00615.29
7.0.150.0040.00415.31
7.0.140.0030.04218.83
7.0.130.0030.00915.61
7.0.120.0060.00615.55
7.0.110.0060.00615.09
7.0.100.0030.00615.54
7.0.90.0130.00015.53
7.0.80.0100.00715.42
7.0.70.0060.00815.56
7.0.60.0050.03817.75
7.0.50.0130.03516.81
7.0.40.0070.03016.79
7.0.30.0290.03616.79
7.0.20.0180.04016.81
7.0.10.0050.03716.87
7.0.00.0100.03916.93
5.6.400.0030.01314.48
5.6.390.0030.00714.47
5.6.380.0000.01314.69
5.6.370.0070.00714.65
5.6.360.0070.00714.86
5.6.350.0130.00614.29
5.6.340.0110.00014.40
5.6.330.0090.00614.66
5.6.320.0080.00614.46
5.6.310.0030.01414.45
5.6.300.0030.00614.86
5.6.290.0000.01614.54
5.6.280.0050.04217.69
5.6.270.0100.00314.54
5.6.260.0050.00514.46
5.6.250.0030.01014.32
5.6.240.0040.00814.25
5.6.230.0070.00714.65
5.6.220.0060.00614.29
5.6.210.0130.03617.51
5.6.200.0060.04816.40
5.6.190.0050.02617.68
5.6.180.2110.02317.46
5.6.170.0170.02717.55
5.6.160.0070.04817.53
5.6.150.0110.02216.15
5.6.140.0080.02816.37
5.6.130.0050.04016.47
5.6.120.0080.03017.80
5.6.110.0050.04917.77
5.6.100.0070.03017.71
5.6.90.0000.05217.70
5.6.80.0050.04817.50
5.6.70.0070.00714.52
5.6.60.0060.00914.50
5.6.50.0000.01014.54
5.6.40.0080.00814.15
5.6.30.0120.00014.63
5.6.20.0040.00414.53
5.6.10.0080.00314.34
5.6.00.0070.00714.39
5.5.380.0060.00614.51
5.5.370.0030.00914.52
5.5.360.0060.00614.19
5.5.350.0020.04817.29
5.5.340.0050.02816.29
5.5.330.0080.02317.39
5.5.320.0150.03417.38
5.5.310.0230.03817.41
5.5.300.0070.02016.30
5.5.290.0030.02516.07
5.5.280.0080.02017.74
5.5.270.0080.03817.72
5.5.260.0050.04217.59
5.5.250.0090.03517.60
5.5.240.2140.02717.13
5.5.230.0000.00914.55
5.5.220.0100.00014.43
5.5.210.0070.00414.46
5.5.200.0030.01014.33
5.5.190.0030.01014.29
5.5.180.0030.01214.43
5.5.170.0030.00614.37
5.5.160.0030.00614.29
5.5.150.0070.00714.35
5.5.140.0090.00614.54
5.5.130.0070.01014.39
5.5.120.0030.01414.49
5.5.110.0060.00614.47
5.5.100.0030.00714.23
5.5.90.0060.00614.36
5.5.80.0110.00414.23
5.5.70.0060.01014.54
5.5.60.0060.01214.49
5.5.50.0030.01314.43
5.5.40.0000.01714.52
5.5.30.0030.01014.15
5.5.20.0080.00814.32
5.5.10.0070.00714.66
5.5.00.0090.00614.29
5.4.450.0350.03315.54
5.4.440.0400.03715.51
5.4.430.0070.03415.65
5.4.420.0380.02615.65
5.4.410.0160.02315.39
5.4.400.0130.02815.28
5.4.390.0170.02715.26
5.4.380.0170.02815.27
5.4.370.0140.02915.28
5.4.360.0250.02715.23
5.4.350.0120.03015.12
5.4.340.0190.02615.17
5.4.330.0070.00711.73
5.4.320.0170.02815.18
5.4.310.0200.02515.22
5.4.300.0180.03315.24
5.4.290.0170.03515.28
5.4.280.0120.03415.26
5.4.270.0150.03415.13
5.4.260.0130.03015.23
5.4.250.0150.03315.18
5.4.240.0130.03215.26
5.4.230.0200.02515.27
5.4.220.0200.03315.16
5.4.210.0100.03915.18
5.4.200.0150.03114.19
5.4.190.0150.03015.16
5.4.180.0100.03515.28
5.4.170.0100.03815.15
5.4.160.0170.02515.22
5.4.150.0160.02815.24
5.4.140.0170.03314.01
5.4.130.0150.02814.09
5.4.120.0080.03314.04
5.4.110.0180.02613.97
5.4.100.0220.02014.09
5.4.90.0150.02813.97
5.4.80.0180.02514.00
5.4.70.0130.03213.94
5.4.60.0110.03114.03
5.4.50.0180.02314.00
5.4.40.0190.02714.03
5.4.30.0130.03514.03
5.4.20.0260.02214.08
5.4.10.0150.02813.97
5.4.00.0120.03013.73
5.3.290.0200.06314.68
5.3.280.0270.05014.63
5.3.270.0300.05014.81
5.3.260.0270.05314.80
5.3.250.0170.05714.80
5.3.240.0230.05314.70
5.3.230.0270.05014.63
5.3.220.0300.04714.57
5.3.210.0230.05714.70
5.3.200.0200.05314.70
5.3.190.0200.05714.60
5.3.180.0270.05014.76
5.3.170.0370.04314.67
5.3.160.0230.05014.56
5.3.150.0330.04314.62
5.3.140.0170.06014.77
5.3.130.0200.07014.59
5.3.120.0230.05014.56
5.3.110.0230.05014.68
5.3.100.0200.05714.09
5.3.90.0230.05014.12
5.3.80.0230.06314.14
5.3.70.0230.04714.14
5.3.60.0230.05014.10
5.3.50.0170.05314.05
5.3.40.0230.05013.97
5.3.30.0330.04013.98
5.3.20.0270.04713.68
5.3.10.0270.04013.70
5.3.00.0230.04713.86
5.2.170.0300.03311.30
5.2.160.0170.04711.18
5.2.150.0270.03311.11
5.2.140.0130.04711.10
5.2.130.0170.04011.07
5.2.120.0130.04711.08
5.2.110.0070.05011.08
5.2.100.0200.04311.16
5.2.90.0170.04011.05
5.2.80.0170.04011.06
5.2.70.0130.04311.07
5.2.60.0200.04311.02
5.2.50.0230.04711.01
5.2.40.0130.04711.13
5.2.30.0270.04710.95
5.2.20.0230.05010.88
5.2.10.0230.04011.02
5.2.00.0130.04310.70
5.1.60.0170.03010.13
5.1.50.0100.0379.95
5.1.40.0130.0439.99
5.1.30.0070.04710.34
5.1.20.0170.03710.40
5.1.10.0170.04710.10
5.1.00.0130.03710.13
5.0.50.0170.0238.57
5.0.40.0070.0338.52
5.0.30.0100.0438.25
5.0.20.0170.0338.21
5.0.10.0170.0378.27
5.0.00.0100.0438.26
4.4.90.0070.0307.60
4.4.80.0070.0237.60
4.4.70.0130.0207.60
4.4.60.0100.0237.60
4.4.50.0100.0237.60
4.4.40.0130.0337.60
4.4.30.0070.0277.60
4.4.20.0100.0237.60
4.4.10.0100.0207.60
4.4.00.0130.0407.60
4.3.110.0100.0307.60
4.3.100.0130.0177.60
4.3.90.0100.0207.60
4.3.80.0100.0337.60
4.3.70.0100.0237.60
4.3.60.0070.0207.60
4.3.50.0070.0277.60
4.3.40.0030.0377.60
4.3.30.0030.0237.60
4.3.20.0070.0207.60
4.3.10.0030.0237.60
4.3.00.0130.0209.29

preferences:
53.01 ms | 400 KiB | 5 Q