diff options
Diffstat (limited to 'vendor/aws/aws-crt-php/src/AWS/CRT/Internal')
-rw-r--r-- | vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Encoding.php | 37 | ||||
-rw-r--r-- | vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php | 29 |
2 files changed, 66 insertions, 0 deletions
diff --git a/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Encoding.php b/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Encoding.php new file mode 100644 index 0000000..75446fc --- /dev/null +++ b/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Encoding.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +namespace AWS\CRT\Internal; + +final class Encoding { + public static function readString(&$buffer) { + list($len, $str) = self::decodeString($buffer); + // Advance by sizeof(length) + strlen(str) + $buffer = substr($buffer, 4 + $len); + return $str; + } + + public static function readStrings($buffer) { + $strings = []; + while (strlen($buffer)) { + $strings []= self::readString($buffer); + } + return $strings; + } + + public static function decodeString($buffer) { + $len = unpack("N", $buffer)[1]; + $buffer = substr($buffer, 4); + $str = unpack("a${len}", $buffer)[1]; + return [$len, $str]; + } + + public static function encodeString($str) { + if (is_array($str)) { + $str = $str[0]; + } + return pack("Na*", strlen($str), $str); + } +} diff --git a/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php b/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php new file mode 100644 index 0000000..7801788 --- /dev/null +++ b/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ +namespace AWS\CRT\Internal; + +use \RuntimeException; + +/** + * @internal + * Forwards calls on to awscrt PHP extension functions + */ +final class Extension { + function __construct() { + if (!extension_loaded('awscrt')) { + throw new RuntimeException('awscrt extension is not loaded'); + } + } + + /** + * Forwards any call made on this object to the extension function of the + * same name with the supplied arguments. Argument type hinting and checking + * occurs at the CRT wrapper. + */ + function __call($name, $args) { + return call_user_func_array($name, $args); + } +} |