更新
This commit is contained in:
13
vendor/alibabacloud/endpoint-util/.gitignore
vendored
Normal file
13
vendor/alibabacloud/endpoint-util/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
composer.lock
|
||||
|
||||
.idea
|
||||
.DS_Store
|
||||
|
||||
cache/
|
||||
*.cache
|
||||
runtime/
|
||||
65
vendor/alibabacloud/endpoint-util/.php_cs.dist
vendored
Normal file
65
vendor/alibabacloud/endpoint-util/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
* This document has been generated with
|
||||
* https://mlocati.github.io/php-cs-fixer-configurator/#version:2.15|configurator
|
||||
* you can change this configuration by importing this file.
|
||||
*/
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setIndent(' ')
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'@PhpCsFixer' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'array_indentation' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'method_separation' => true,
|
||||
'single_quote' => true,
|
||||
'declare_equal_normalize' => true,
|
||||
'function_typehint_space' => true,
|
||||
'hash_to_slash_comment' => true,
|
||||
'include' => true,
|
||||
'lowercase_cast' => true,
|
||||
'no_multiline_whitespace_before_semicolons' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_spaces_around_offset' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_class_element_per_statement' => true,
|
||||
'space_after_semicolon' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
'no_extra_consecutive_blank_lines' => [
|
||||
'curly_brace_block',
|
||||
'extra',
|
||||
'parenthesis_brace_block',
|
||||
'square_brace_block',
|
||||
'throw',
|
||||
'use',
|
||||
],
|
||||
'binary_operator_spaces' => [
|
||||
'align_double_arrow' => true,
|
||||
'align_equals' => true,
|
||||
],
|
||||
'braces' => [
|
||||
'allow_single_line_closure' => true,
|
||||
],
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('tests')
|
||||
->in(__DIR__)
|
||||
);
|
||||
13
vendor/alibabacloud/endpoint-util/LICENSE
vendored
Normal file
13
vendor/alibabacloud/endpoint-util/LICENSE
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
31
vendor/alibabacloud/endpoint-util/README-CN.md
vendored
Normal file
31
vendor/alibabacloud/endpoint-util/README-CN.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
English | [简体中文](README-CN.md)
|
||||
|
||||

|
||||
|
||||
## Alibaba Cloud Endpoint Library for PHP
|
||||
|
||||
## Installation
|
||||
|
||||
### Composer
|
||||
|
||||
```bash
|
||||
composer require alibabacloud/endpoint-util
|
||||
```
|
||||
|
||||
## Issues
|
||||
|
||||
[Opening an Issue](https://github.com/aliyun/endpoint-util/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
||||
|
||||
## Changelog
|
||||
|
||||
Detailed changes for each release are documented in the [release notes](./ChangeLog.txt).
|
||||
|
||||
## References
|
||||
|
||||
* [Latest Release](https://github.com/aliyun/endpoint-util)
|
||||
|
||||
## License
|
||||
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
31
vendor/alibabacloud/endpoint-util/README.md
vendored
Normal file
31
vendor/alibabacloud/endpoint-util/README.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
[English](README.md) | 简体中文
|
||||
|
||||

|
||||
|
||||
## Alibaba Cloud Endpoint Library for PHP
|
||||
|
||||
## 安装
|
||||
|
||||
### Composer
|
||||
|
||||
```bash
|
||||
composer require alibabacloud/endpoint-util
|
||||
```
|
||||
|
||||
## 问题
|
||||
|
||||
[提交 Issue](https://github.com/aliyun/endpoint-util/issues/new),不符合指南的问题可能会立即关闭。
|
||||
|
||||
## 发行说明
|
||||
|
||||
每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。
|
||||
|
||||
## 相关
|
||||
|
||||
* [最新源码](https://github.com/aliyun/endpoint-util)
|
||||
|
||||
## 许可证
|
||||
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
42
vendor/alibabacloud/endpoint-util/composer.json
vendored
Normal file
42
vendor/alibabacloud/endpoint-util/composer.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "alibabacloud/endpoint-util",
|
||||
"description": "Alibaba Cloud Endpoint Library for PHP",
|
||||
"type": "library",
|
||||
"license": "Apache-2.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alibaba Cloud SDK",
|
||||
"email": "sdk-team@alibabacloud.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Endpoint\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Endpoint\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"fixer": "php-cs-fixer fix ./",
|
||||
"test": [
|
||||
"@clearCache",
|
||||
"./vendor/bin/phpunit --colors=always"
|
||||
],
|
||||
"clearCache": "rm -rf cache/*"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"prefer-stable": true
|
||||
}
|
||||
32
vendor/alibabacloud/endpoint-util/phpunit.xml
vendored
Normal file
32
vendor/alibabacloud/endpoint-util/phpunit.xml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false"
|
||||
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
|
||||
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="All">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>integration</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-html" target="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="cache/coverage.clover"/>
|
||||
</logging>
|
||||
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
61
vendor/alibabacloud/endpoint-util/src/Endpoint.php
vendored
Normal file
61
vendor/alibabacloud/endpoint-util/src/Endpoint.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Endpoint;
|
||||
|
||||
/**
|
||||
* Get endpoint.
|
||||
*/
|
||||
class Endpoint
|
||||
{
|
||||
const ENDPOINT_TYPE_REGIONAL = 'regional';
|
||||
const ENDPOINT_TYPE_CENTRAL = 'central';
|
||||
|
||||
const REGIONAL_RULES = '<product><suffix><network>.<region_id>.aliyuncs.com';
|
||||
const CENTRAL_RULES = '<product><suffix><network>.aliyuncs.com';
|
||||
|
||||
/**
|
||||
* @param string $product required
|
||||
* @param string $regionId optional It will be required when endpoint type is 'regional'
|
||||
* @param string $endpointType optional regional|central
|
||||
* @param string $network optional
|
||||
* @param string $suffix optional
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getEndpointRules($product, $regionId, $endpointType = '', $network = '', $suffix = '')
|
||||
{
|
||||
if (empty($product)) {
|
||||
throw new \InvalidArgumentException('Product name cannot be empty.');
|
||||
}
|
||||
$endpoint = self::REGIONAL_RULES;
|
||||
if (self::ENDPOINT_TYPE_REGIONAL === $endpointType) {
|
||||
if (empty($regionId)) {
|
||||
throw new \InvalidArgumentException('RegionId is empty, please set a valid RegionId');
|
||||
}
|
||||
$endpoint = self::render($endpoint, 'region_id', strtolower($regionId));
|
||||
} elseif (self::ENDPOINT_TYPE_CENTRAL === $endpointType) {
|
||||
$endpoint = self::CENTRAL_RULES;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid EndpointType');
|
||||
}
|
||||
if (!empty($network) && 'public' !== $network) {
|
||||
$endpoint = self::render($endpoint, 'network', '-' . $network);
|
||||
} else {
|
||||
$endpoint = self::render($endpoint, 'network', '');
|
||||
}
|
||||
if (!empty($suffix)) {
|
||||
$endpoint = self::render($endpoint, 'suffix', '-' . $suffix);
|
||||
} else {
|
||||
$endpoint = self::render($endpoint, 'suffix', '');
|
||||
}
|
||||
|
||||
return self::render($endpoint, 'product', strtolower($product));
|
||||
}
|
||||
|
||||
private static function render($str, $tag, $replace)
|
||||
{
|
||||
return str_replace('<' . $tag . '>', $replace, $str);
|
||||
}
|
||||
}
|
||||
58
vendor/alibabacloud/endpoint-util/tests/EndpointTest.php
vendored
Normal file
58
vendor/alibabacloud/endpoint-util/tests/EndpointTest.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Endpoint\Tests;
|
||||
|
||||
use AlibabaCloud\Endpoint\Endpoint;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class EndpointTest extends TestCase
|
||||
{
|
||||
public function testGetEndpointWhenInvalidProduct()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Product name cannot be empty.');
|
||||
Endpoint::getEndpointRules('', '', '', '');
|
||||
}
|
||||
|
||||
public function testGetEndpointWhenInvalidEndpointType()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Invalid EndpointType');
|
||||
Endpoint::getEndpointRules('ecs', '', 'fake endpoint type', '');
|
||||
}
|
||||
|
||||
public function testGetEndpointWhenInvalidRegionId()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('RegionId is empty, please set a valid RegionId');
|
||||
Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_REGIONAL, '');
|
||||
}
|
||||
|
||||
public function testGetEndpointCentral()
|
||||
{
|
||||
$endpoint = Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_CENTRAL);
|
||||
$this->assertEquals('ecs.aliyuncs.com', $endpoint);
|
||||
}
|
||||
|
||||
public function testGetEndpointRegional()
|
||||
{
|
||||
$endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL);
|
||||
$this->assertEquals('ecs.cn-hangzhou.aliyuncs.com', $endpoint);
|
||||
}
|
||||
|
||||
public function testGetEndpointRegionalWithNetwork()
|
||||
{
|
||||
$endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal');
|
||||
$this->assertEquals('ecs-internal.cn-hangzhou.aliyuncs.com', $endpoint);
|
||||
}
|
||||
|
||||
public function testGetEndpointRegionalWithSuffix()
|
||||
{
|
||||
$endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal', 'test');
|
||||
$this->assertEquals('ecs-test-internal.cn-hangzhou.aliyuncs.com', $endpoint);
|
||||
}
|
||||
}
|
||||
3
vendor/alibabacloud/endpoint-util/tests/bootstrap.php
vendored
Normal file
3
vendor/alibabacloud/endpoint-util/tests/bootstrap.php
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
Reference in New Issue
Block a user