Skip to content

Commit 19cbf23

Browse files
committed
init
0 parents  commit 19cbf23

23 files changed

Lines changed: 812 additions & 0 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
.DS_Store
3+
vendor
4+
.php_cs.cache
5+
.phpunit.result.cache
6+
composer.lock
7+
coverage

.php_cs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->files()
4+
->name('*.php')
5+
->in(__DIR__ . '/src')
6+
->in(__DIR__ . '/tests')
7+
;
8+
return PhpCsFixer\Config::create()
9+
->setRules(array(
10+
'@PSR2' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
13+
'blank_line_after_namespace' => true,
14+
'blank_line_after_opening_tag' => false,
15+
'blank_line_before_return' => false,
16+
'braces' => ['allow_single_line_closure' => false],
17+
'cast_spaces' => true,
18+
'class_definition' => ['singleLine' => false, 'singleItemSingleLine' => true, 'multiLineExtendsEachSingleLine' => true],
19+
'class_keyword_remove' => false,
20+
'combine_consecutive_unsets' => true,
21+
'concat_space' => false,
22+
'declare_equal_normalize' => ['space' => 'single'],
23+
'declare_strict_types' => false,
24+
'elseif' => true,
25+
'encoding' => true,
26+
'full_opening_tag' => true,
27+
'function_declaration' => true,
28+
'function_typehint_space' => true,
29+
'general_phpdoc_annotation_remove' => ['expectedExceptionMessageRegExp', 'expectedException', 'expectedExceptionMessage'],
30+
'hash_to_slash_comment' => true,
31+
'header_comment' => false,
32+
'heredoc_to_nowdoc' => true,
33+
'include' => true,
34+
'indentation_type' => true,
35+
'line_ending' => true,
36+
'linebreak_after_opening_tag' => true,
37+
'lowercase_cast' => true,
38+
'lowercase_constants' => true,
39+
'lowercase_keywords' => true,
40+
'mb_str_functions' => false,
41+
'method_argument_space' => true,
42+
'method_separation' => true,
43+
'native_function_casing' => true,
44+
'native_function_invocation' => false,
45+
'new_with_braces' => true,
46+
'no_blank_lines_after_class_opening' => true,
47+
'no_blank_lines_after_phpdoc' => false,
48+
'no_blank_lines_before_namespace' => false,
49+
'no_closing_tag' => true,
50+
'no_empty_comment' => true,
51+
'no_empty_phpdoc' => true,
52+
'no_empty_statement' => true,
53+
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
54+
'no_leading_import_slash' => true,
55+
'no_leading_namespace_whitespace' => true,
56+
'no_mixed_echo_print' => ['use' => 'echo'],
57+
'no_multiline_whitespace_around_double_arrow' => true,
58+
'no_multiline_whitespace_before_semicolons' => true,
59+
'no_short_bool_cast' => true,
60+
'no_short_echo_tag' => true,
61+
'no_singleline_whitespace_before_semicolons' => true,
62+
'no_spaces_after_function_name' => true,
63+
'no_spaces_around_offset' => true,
64+
'no_spaces_inside_parenthesis' => true,
65+
'no_trailing_comma_in_list_call' => true,
66+
'no_trailing_comma_in_singleline_array' => true,
67+
'no_trailing_whitespace' => true,
68+
'no_trailing_whitespace_in_comment' => true,
69+
'no_unneeded_control_parentheses' => true,
70+
'no_unused_imports' => true,
71+
'no_useless_else' => true,
72+
'no_useless_return' => true,
73+
'no_whitespace_before_comma_in_array' => true,
74+
'no_whitespace_in_blank_line' => true,
75+
'normalize_index_brace' => true,
76+
'not_operator_with_space' => false,
77+
'not_operator_with_successor_space' => false,
78+
'object_operator_without_whitespace' => true,
79+
'ordered_class_elements' => false,
80+
'ordered_imports' => true,
81+
'php_unit_fqcn_annotation' => true,
82+
'php_unit_strict' => false,
83+
'phpdoc_add_missing_param_annotation' => true,
84+
'phpdoc_align' => true,
85+
'phpdoc_inline_tag' => true,
86+
'phpdoc_no_access' => true,
87+
'phpdoc_no_alias_tag' => ['property-read' => 'property', 'property-write' => 'property', 'type' => 'var'],
88+
'phpdoc_no_empty_return' => true,
89+
'phpdoc_no_package' => true,
90+
'phpdoc_no_useless_inheritdoc' => true,
91+
'phpdoc_order' => true,
92+
'phpdoc_return_self_reference' => true,
93+
'phpdoc_scalar' => true,
94+
'phpdoc_separation' => false,
95+
'phpdoc_single_line_var_spacing' => true,
96+
'phpdoc_summary' => false,
97+
'phpdoc_to_comment' => true,
98+
'phpdoc_trim' => true,
99+
'phpdoc_types' => true,
100+
'phpdoc_var_without_name' => true,
101+
'pow_to_exponentiation' => false,
102+
'pre_increment' => true,
103+
'protected_to_private' => true,
104+
'return_type_declaration' => true,
105+
'semicolon_after_instruction' => true,
106+
'short_scalar_cast' => true,
107+
'single_blank_line_at_eof' => true,
108+
'single_blank_line_before_namespace' => false,
109+
'single_class_element_per_statement' => true,
110+
'single_import_per_statement' => true,
111+
'single_line_after_imports' => true,
112+
'single_quote' => true,
113+
'space_after_semicolon' => true,
114+
'standardize_not_equals' => true,
115+
'strict_param' => false,
116+
'switch_case_semicolon_to_colon' => true,
117+
'switch_case_space' => true,
118+
'ternary_operator_spaces' => true,
119+
'ternary_to_null_coalescing' => false,
120+
'trailing_comma_in_multiline_array' => true,
121+
'trim_array_spaces' => true,
122+
'unary_operator_spaces' => true,
123+
'visibility_required' => true,
124+
'whitespace_after_comma_in_array' => true,
125+
))
126+
->setFinder($finder)
127+
;

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sudo: true
2+
3+
language: php
4+
5+
php:
6+
- 7.1.9
7+
8+
cache:
9+
directories:
10+
- vendor
11+
- "$HOME/.composer/cache"
12+
13+
script:
14+
- composer install
15+
- phpunit

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 XiaoDi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# think-short-url
2+
### 短地址生成
3+
4+
### 安装
5+
```
6+
$ composer require xiaodi/think-short-url:dev-master
7+
```
8+
9+
### 百度
10+
#### 创建
11+
```php
12+
use ShortUrl\Facade\ShortUrl;
13+
14+
ShortUrl::make('baidu')->create('https://www.baidu.com');
15+
```
16+
17+
#### 还原
18+
```php
19+
use ShortUrl\Facade\ShortUrl;
20+
21+
ShortUrl::make('baidu')->query('https://dwz.cn/JCRnHXWE');
22+
```
23+
24+
#### 删除
25+
```php
26+
use ShortUrl\Facade\ShortUrl;
27+
28+
ShortUrl::make('baidu')->delete('JCRnHXWE');
29+
```
30+
31+
### 新浪
32+
#### 创建
33+
```php
34+
use ShortUrl\Facade\ShortUrl;
35+
36+
ShortUrl::make('sina')->create('https://www.baidu.com');
37+
```
38+
39+
### 快捷助手
40+
```php
41+
// 生成百度短链
42+
shorturl_baidu($url);
43+
44+
// 生成新浪短链
45+
shorturl_sina($url);
46+
```

composer.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "xiaodi/think-short-url",
3+
"description": "ThinkPHP ShortUrl Component",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "xiaodi",
8+
"email": "liangjinbiao@live.com",
9+
"homepage": "http://www.xiaodim.com",
10+
"role": "Developer"
11+
}
12+
],
13+
"minimum-stability": "dev",
14+
"keywords": [
15+
"php",
16+
"thinkphp",
17+
"thinkphp-component"
18+
],
19+
"require": {
20+
"topthink/framework": "6.0.*",
21+
"guzzlehttp/guzzle": "^6.4",
22+
"symfony/dom-crawler": "^4.2",
23+
"symfony/css-selector": "^4.3"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"ShortUrl\\": "src/"
28+
},
29+
"files": [
30+
"src/helper.php"
31+
]
32+
},
33+
"extra": {
34+
"think": {
35+
"services": [
36+
"ShortUrl\\ShortUrlService"
37+
],
38+
"config": {
39+
"short_url": "src/config/config.php"
40+
}
41+
}
42+
},
43+
"autoload-dev": {
44+
"psr-4": {
45+
"ShortUrl\\Test\\": "tests/"
46+
}
47+
},
48+
"scripts": {
49+
"test": [
50+
"phpunit"
51+
],
52+
"cs-fixs": "php-cs-fixer fix .",
53+
"coverage": "phpunit --coverage-html=coverage"
54+
},
55+
"require-dev": {
56+
"friendsofphp/php-cs-fixer": "^2.15",
57+
"phpunit/phpunit": "^6.2",
58+
"mockery/mockery": "^1.2"
59+
}
60+
}

phpunit.xml.dist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
beStrictAboutTestsThatDoNotTestAnything="false"
5+
bootstrap="tests/bootstrap.php"
6+
colors="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnError="false"
12+
stopOnFailure="false"
13+
verbose="true"
14+
>
15+
<testsuites>
16+
<testsuite name="Think ShortUrl Test Suite">
17+
<directory suffix="Test.php">./tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
<filter>
21+
<whitelist processUncoveredFilesFromWhitelist="true">
22+
<directory suffix=".php">./src</directory>
23+
<exclude>
24+
<file>./src/ShortUrlService.php</file>
25+
<file>./src/helper.php</file>
26+
<file>./src/config/config.php</file>
27+
</exclude>
28+
</whitelist>
29+
</filter>
30+
</phpunit>

src/Contract/ShortUrlInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace ShortUrl\Contract;
4+
5+
interface ShortUrlInterface
6+
{
7+
public function __construct($options = []);
8+
9+
public function create($arguments);
10+
}

src/Exception/Exception.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace ShortUrl\Exception;
4+
5+
class Exception extends \Exception
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace ShortUrl\Exception;
4+
5+
class TokenInvalidException extends \Exception
6+
{
7+
}

0 commit comments

Comments
 (0)