3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace texdc\cicerone; /** * 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); self::$instances[$this->value] = $this; } /** * @param string $aMethod * @param array $arguments * @return self */ public static function __callStatic($aMethod, $arguments = []) { if (!isset(self::$instances[$aMethod])) { $instance = new static($aMethod); $aMethod = $instance->value; } return self::$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(HttpMethod::sanitize(' gofu '));

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.0080.00816.61
8.3.50.0160.00521.89
8.3.40.0040.01118.64
8.3.30.0100.00318.95
8.3.20.0080.00020.21
8.3.10.0050.00321.90
8.3.00.0040.00419.13
8.2.180.0110.01116.88
8.2.170.0110.01122.96
8.2.160.0070.01122.14
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0000.00826.16
8.2.120.0050.00319.64
8.2.110.0070.00320.74
8.2.100.0090.00317.63
8.2.90.0060.00319.25
8.2.80.0040.00417.97
8.2.70.0030.00617.63
8.2.60.0100.00019.41
8.2.50.0000.00818.07
8.2.40.0040.00419.82
8.2.30.0050.00218.10
8.2.20.0030.00517.57
8.2.10.0040.00417.91
8.2.00.0000.00817.66
8.1.280.0040.01425.92
8.1.270.0060.00318.92
8.1.260.0060.00326.35
8.1.250.0080.00028.09
8.1.240.0090.00021.00
8.1.230.0070.00717.42
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0060.00317.23
8.1.190.0030.00517.10
8.1.180.0040.00418.10
8.1.170.0040.00420.50
8.1.160.0070.00021.96
8.1.150.0030.00618.86
8.1.140.0000.00717.45
8.1.130.0030.00317.67
8.1.120.0000.00917.34
8.1.110.0000.00717.35
8.1.100.0040.00417.46
8.1.90.0000.00717.33
8.1.80.0000.00717.37
8.1.70.0000.00717.46
8.1.60.0030.00617.48
8.1.50.0070.00317.58
8.1.40.0060.00317.37
8.1.30.0030.00517.52
8.1.20.0040.00417.59
8.1.10.0040.00417.42
8.1.00.0070.00017.38
8.0.300.0000.00718.77
8.0.290.0000.00716.63
8.0.280.0000.00718.46
8.0.270.0040.00417.27
8.0.260.0000.00617.21
8.0.250.0070.00016.89
8.0.240.0040.00416.91
8.0.230.0000.00716.95
8.0.220.0050.00216.75
8.0.210.0050.00216.88
8.0.200.0080.00016.98
8.0.190.0040.00416.97
8.0.180.0050.00216.90
8.0.170.0050.00416.94
8.0.160.0070.00016.88
8.0.150.0000.00716.74
8.0.140.0000.00816.71
8.0.130.0000.00713.24
8.0.120.0060.00316.82
8.0.110.0080.00016.88
8.0.100.0040.00416.88
8.0.90.0030.00516.73
8.0.80.0060.00916.79
8.0.70.0000.00716.83
8.0.60.0050.00316.87
8.0.50.0000.00816.86
8.0.30.0130.00816.91
8.0.20.0140.00617.40
8.0.10.0040.00416.77
8.0.00.0090.00916.73
7.4.330.0000.00515.03
7.4.320.0060.00016.48
7.4.300.0000.00716.38
7.4.290.0030.00316.61
7.4.280.0040.00416.57
7.4.270.0070.00016.40
7.4.260.0040.00416.55
7.4.250.0000.00716.57
7.4.240.0060.00316.50
7.4.230.0000.00716.57
7.4.220.0170.01016.49
7.4.210.0070.00816.62
7.4.200.0000.00716.57
7.4.160.0120.00616.36
7.4.150.0140.00317.40
7.4.140.0100.01017.86
7.4.130.0100.01116.34
7.4.120.0130.00516.45
7.4.110.0090.00916.41
7.4.100.0140.00316.46
7.4.90.0060.01216.40
7.4.80.0140.00319.39
7.4.70.0110.00716.50
7.4.60.0120.00416.46
7.4.50.0040.00016.61
7.4.40.0130.00916.41
7.4.30.0090.01216.36
7.4.10.0090.00614.76
7.4.00.0100.00814.76
7.3.330.0000.00513.27
7.3.320.0070.00713.28
7.3.310.0000.00816.30
7.3.300.0030.00316.31
7.3.290.0000.00716.27
7.3.280.0080.00816.29
7.3.270.0090.00917.40
7.3.260.0140.00516.26
7.3.250.0100.00816.15
7.3.240.0110.00716.27
7.3.230.0140.00316.39
7.3.210.0060.01616.22
7.3.200.0150.00719.39
7.3.190.0090.00916.41
7.3.180.0090.00916.08
7.3.170.0070.01416.45
7.3.160.0070.01016.37
7.3.130.0090.00914.79
7.3.120.0070.01114.61
7.3.110.0090.01014.62
7.3.100.0070.00714.87
7.3.90.0080.00314.70
7.3.80.0030.00914.75
7.3.70.0050.00814.70
7.3.60.0060.00714.71
7.3.50.0060.00814.74
7.3.40.0070.00714.79
7.3.30.0060.00714.79
7.3.20.0040.00916.45
7.3.10.0080.00716.54
7.3.00.0090.00316.50
7.2.330.0060.01216.42
7.2.320.0040.01616.64
7.2.310.0100.00616.60
7.2.300.0100.01316.43
7.2.290.0120.00916.70
7.2.260.0080.01014.98
7.2.250.0100.00614.84
7.2.240.0060.01014.98
7.2.230.0070.00914.88
7.2.220.0040.01114.96
7.2.210.0050.01014.88
7.2.200.0060.00714.97
7.2.190.0050.01014.89
7.2.180.0050.00714.92
7.2.170.0040.01214.89
7.2.160.0090.00315.08
7.2.150.0050.00916.81
7.2.140.0030.00816.81
7.2.130.0030.01316.81
7.2.120.0050.00916.71
7.2.110.0070.00716.72
7.2.100.0080.00616.75
7.2.90.0030.01116.78
7.2.80.0000.01416.62
7.2.70.0030.01416.86
7.2.60.0050.00716.86
7.2.50.0050.01016.69
7.2.40.0060.00616.74
7.2.30.0080.00616.74
7.2.20.0060.00716.99
7.2.10.0070.00516.59
7.2.00.0060.00717.68
7.1.330.0070.00615.60
7.1.320.0050.00615.73
7.1.310.0040.01115.49
7.1.300.0030.01015.54
7.1.290.0020.01015.66
7.1.280.0050.00915.57
7.1.270.0060.00615.71
7.1.260.0030.01215.69
7.1.250.0060.00815.71
7.1.240.0050.00515.55
7.1.230.0030.01015.71
7.1.220.0070.00715.68
7.1.210.0080.00515.80
7.1.200.0040.01215.73
7.1.190.0070.00215.67
7.1.180.0030.01015.65
7.1.170.0050.00915.54
7.1.160.0050.00715.66
7.1.150.0050.00715.62
7.1.140.0060.00615.58
7.1.130.0050.00615.51
7.1.120.0020.01215.60
7.1.110.0040.00815.72
7.1.100.0070.00516.34
7.1.90.0030.01015.61
7.1.80.0050.00915.78
7.1.70.0040.00716.01
7.1.60.0050.00516.25
7.1.50.0080.00916.01
7.1.40.0050.00815.72
7.1.30.0040.01215.68
7.1.20.0030.00615.59
7.1.10.0050.00615.74
7.1.00.0020.03417.88
7.0.330.0070.00715.21
7.0.320.0030.00715.12
7.0.310.0070.00615.42
7.0.300.0010.00815.27
7.0.290.0060.00615.28
7.0.280.0080.00615.34
7.0.270.0050.00815.29
7.0.260.0020.00915.31
7.0.250.0070.00215.47
7.0.240.0060.00815.48
7.0.230.0020.01115.45
7.0.220.0020.00815.44
7.0.210.0040.00815.34
7.0.200.0020.01115.68
7.0.190.0030.01115.24
7.0.180.0050.00715.13
7.0.170.0060.00715.45
7.0.160.0040.00615.22
7.0.150.0120.00215.30
7.0.140.0010.02817.51
7.0.130.0060.00815.46
7.0.120.0030.00815.45
7.0.110.0060.00415.46
7.0.100.0100.00415.27
7.0.90.0070.00415.46
7.0.80.0070.00515.48
7.0.70.0070.00415.24
7.0.60.0080.02816.82
7.0.50.0110.01616.15
7.0.40.0080.02615.75
7.0.30.0110.01715.68
7.0.20.0100.03215.74
7.0.10.0160.02715.60
7.0.00.0070.02915.64
5.6.400.0050.00814.06
5.6.390.0070.00514.13
5.6.380.0050.00914.28
5.6.370.0060.00714.32
5.6.360.0020.01114.19
5.6.350.0030.00814.22
5.6.340.0030.00914.19
5.6.330.0060.00614.15
5.6.320.0070.00714.20
5.6.310.0030.01014.25
5.6.300.0080.00614.24
5.6.290.0030.00914.32
5.6.280.0020.01214.20
5.6.270.0080.00314.10
5.6.260.0000.01414.35
5.6.250.0070.00714.16
5.6.240.0070.00914.09
5.6.230.0060.00514.24
5.6.220.0070.00714.16
5.6.210.0050.03016.40
5.6.200.0030.03215.61
5.6.190.0020.03216.38
5.6.180.0110.02016.30
5.6.170.0170.02816.26
5.6.160.0030.02316.33
5.6.150.0060.01715.51
5.6.140.0030.02015.52
5.6.130.0040.02115.37
5.6.120.0050.01916.37
5.6.110.0030.02216.41
5.6.100.0060.02016.46
5.6.90.0040.03516.50
5.6.80.0050.03316.11
5.6.70.0160.02116.25
5.6.60.0050.00714.04
5.6.50.0020.00914.05
5.6.40.0020.01113.93
5.6.30.0050.00914.32
5.6.20.0050.00514.05
5.6.10.0050.01014.19
5.6.00.0040.00814.33
5.5.380.0030.00814.17
5.5.370.0080.00514.26
5.5.360.0050.00614.16
5.5.350.0080.03116.20
5.5.340.0070.01815.42
5.5.330.0060.02916.21
5.5.320.0090.03216.17
5.5.310.0200.02916.20
5.5.300.0070.02515.49
5.5.290.0060.01415.38
5.5.280.0080.03316.34
5.5.270.0050.01716.40
5.5.260.0090.01716.21
5.5.250.0030.03516.31
5.5.240.0070.02516.16
5.5.230.0020.01214.12
5.5.220.0050.00714.25
5.5.210.0030.01114.06
5.5.200.0020.00814.30
5.5.190.0030.00614.25
5.5.180.0050.00714.13
5.5.170.0000.01013.99
5.5.160.0050.00714.18
5.5.150.0070.00714.11
5.5.140.0020.01014.00
5.5.130.0050.00914.04
5.5.120.0060.00914.07
5.5.110.0020.00814.00
5.5.100.0020.01214.14
5.5.90.0030.01014.16
5.5.80.0090.00514.23
5.5.70.0020.01314.17
5.5.60.0060.00713.75
5.5.50.0090.00413.98
5.5.40.0040.00914.25
5.5.30.0110.00514.07
5.5.20.0050.01014.03
5.5.10.0020.01313.81
5.5.00.0050.00413.99
5.4.450.0650.01614.23
5.4.440.0730.02214.13
5.4.430.0650.01714.29
5.4.420.0700.01414.24
5.4.410.0670.01714.08
5.4.400.0750.01313.96
5.4.390.0670.01513.99
5.4.380.0710.01514.06
5.4.370.0640.01613.97
5.4.360.0590.01814.02
5.4.350.0730.01914.09
5.4.340.0620.02014.05
5.4.330.0050.00511.70
5.4.320.0690.01814.17
5.4.310.0750.01514.08
5.4.300.0780.01413.98
5.4.290.0690.01614.10
5.4.280.0690.01713.99
5.4.270.0740.01714.09
5.4.260.0650.01814.01
5.4.250.0720.01914.06
5.4.240.0730.02114.03
5.4.230.0670.01614.07
5.4.220.0650.01913.99
5.4.210.0790.01714.14
5.4.200.0790.01614.13
5.4.190.0790.01814.12
5.4.180.0700.01514.00
5.4.170.0670.01813.93
5.4.160.0700.01314.04
5.4.150.0680.01714.04
5.4.140.0700.01413.25
5.4.130.0730.01813.13
5.4.120.0700.01613.17
5.4.110.0780.01513.08
5.4.100.0700.01513.30
5.4.90.0690.01513.20
5.4.80.0840.01913.23
5.4.70.0770.01513.13
5.4.60.0700.01713.19
5.4.50.0720.01913.13
5.4.40.0700.01813.20
5.4.30.0740.01713.14
5.4.20.0740.01913.25
5.4.10.0750.01713.28
5.4.00.0720.02213.01
5.3.290.1970.04014.89
5.3.280.2000.05014.50
5.3.270.2170.04014.57
5.3.260.2270.04014.82
5.3.250.2230.04314.72
5.3.240.2300.04014.60
5.3.230.2230.03714.82
5.3.220.2200.03014.53
5.3.210.2200.03314.62
5.3.200.2230.03314.68
5.3.190.2200.04714.48
5.3.180.2200.04014.46
5.3.170.2270.04714.68
5.3.160.2000.03714.79
5.3.150.2100.03314.57
5.3.140.2370.04314.78
5.3.130.2170.04014.70
5.3.120.2270.04314.69
5.3.110.2200.05314.45
5.3.100.2300.04314.26
5.3.90.2330.03714.24
5.3.80.2230.03713.91
5.3.70.2270.04013.92
5.3.60.2130.04314.00
5.3.50.2200.04013.85
5.3.40.2300.04013.95
5.3.30.2200.04313.98
5.3.20.2270.03713.70
5.3.10.2030.03013.71
5.3.00.2230.04013.61
5.2.170.1970.03311.00
5.2.160.1100.02311.23
5.2.150.1730.02310.99
5.2.140.1570.03311.16
5.2.130.1630.03011.14
5.2.120.1530.02310.96
5.2.110.1870.03010.94
5.2.100.1730.02711.12
5.2.90.1670.03311.02
5.2.80.1700.03010.95
5.2.70.1730.03011.01
5.2.60.1730.03010.91
5.2.50.1670.03011.16
5.2.40.1370.02310.85
5.2.30.1370.02710.82
5.2.20.1370.02710.90
5.2.10.1330.03010.82
5.2.00.1370.02710.63
5.1.60.1430.02010.05
5.1.50.1400.02710.07
5.1.40.1330.02310.07
5.1.30.1400.02710.38
5.1.20.1330.02710.27
5.1.10.1370.02310.18
5.1.00.1730.02710.19
5.0.50.0800.0208.43
5.0.40.0800.0238.39
5.0.30.0830.0238.20
5.0.20.0900.0278.34
5.0.10.0670.0208.07
5.0.00.0800.0478.05
4.4.90.0870.0237.65
4.4.80.0770.0177.65
4.4.70.0670.0177.65
4.4.60.0630.0177.65
4.4.50.0800.0137.65
4.4.40.0870.0407.65
4.4.30.0870.0207.65
4.4.20.0900.0177.65
4.4.10.0830.0177.65
4.4.00.0830.0337.65
4.3.110.0630.0177.65
4.3.100.0870.0207.65
4.3.90.0800.0177.65
4.3.80.0830.0377.65
4.3.70.0900.0207.65
4.3.60.0930.0237.65
4.3.50.0700.0177.65
4.3.40.0870.0307.65
4.3.30.0430.0307.65
4.3.20.0370.0207.65
4.3.10.0500.0277.65
4.3.00.0470.0277.65

preferences:
54.56 ms | 401 KiB | 5 Q