-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 35418e4
Showing
18 changed files
with
419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
.gitignore export-ignore | ||
.php_cs export-ignore | ||
.scrutinizer.yml export-ignore | ||
.styleci.yml export-ignore | ||
.travis.yml export-ignore | ||
phpspec.yml.ci export-ignore | ||
phpspec.yml.dist export-ignore | ||
phpunit.xml.dist export-ignore | ||
spec/ export-ignore | ||
tests/ export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributing | ||
|
||
Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
| Q | A | ||
| ------------ | --- | ||
| Bug? | no | ||
| New Feature? | no | ||
| Version | Specific version or SHA of a commit | ||
|
||
|
||
#### Actual Behavior | ||
|
||
What is the actual behavior? | ||
|
||
|
||
#### Expected Behavior | ||
|
||
What is the behavior you expect? | ||
|
||
|
||
#### Steps to Reproduce | ||
|
||
What are the steps to reproduce this bug? Please add code examples, | ||
screenshots or links to GitHub repositories that reproduce the problem. | ||
|
||
|
||
#### Possible Solutions | ||
|
||
If you have already ideas how to solve the issue, add them here. | ||
(remove this section if not needed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
| Q | A | ||
| --------------- | --- | ||
| Bug fix? | no|yes | ||
| New feature? | no|yes | ||
| BC breaks? | no|yes | ||
| Deprecations? | no|yes | ||
| Related tickets | fixes #X, partially #Y, mentioned in #Z | ||
| Documentation | if this is a new feature, link to pull request in https://github.com/php-http/documentation that adds relevant documentation | ||
| License | MIT | ||
|
||
|
||
#### What's in this PR? | ||
|
||
Explain what the changes in this PR do. | ||
|
||
|
||
#### Why? | ||
|
||
Which problem does the PR fix? (remove this section if you linked an issue above) | ||
|
||
|
||
#### Example Usage | ||
|
||
``` php | ||
// If you added new features, show examples of how to use them here | ||
// (remove this section if not a new feature) | ||
|
||
$foo = new Foo(); | ||
|
||
// Now we can do | ||
$foo->doSomething(); | ||
``` | ||
|
||
|
||
#### Checklist | ||
|
||
- [ ] Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix | ||
- [ ] Documentation pull request created (if not simply a bugfix) | ||
|
||
|
||
#### To Do | ||
|
||
- [ ] If the PR is not complete but you want to discuss the approach, list what remains to be done here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build/ | ||
vendor/ | ||
composer.lock | ||
phpspec.yml | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
/* | ||
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally | ||
* with composer. | ||
* | ||
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge | ||
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer | ||
*/ | ||
|
||
use SLLH\StyleCIBridge\ConfigBridge; | ||
|
||
return ConfigBridge::create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
filter: | ||
paths: [src/*] | ||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
tools: | ||
external_code_coverage: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
preset: symfony | ||
|
||
finder: | ||
exclude: | ||
- "spec" | ||
path: | ||
- "src" | ||
- "tests" | ||
|
||
enabled: | ||
- short_array_syntax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache/files | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
env: | ||
global: | ||
- TEST_COMMAND="composer test" | ||
|
||
branches: | ||
except: | ||
- /^analysis-.*$/ | ||
|
||
matrix: | ||
fast_finish: true | ||
include: | ||
- php: 5.4 | ||
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" | ||
|
||
before_install: | ||
- travis_retry composer self-update | ||
|
||
install: | ||
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction | ||
|
||
script: | ||
- $TEST_COMMAND | ||
|
||
after_success: | ||
- if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi | ||
- if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Change Log | ||
|
||
|
||
## 1.0.0 - 2016-05-05 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Stopwatch Plugin | ||
|
||
[![Latest Version](https://img.shields.io/github/release/php-http/stopwatch-plugin.svg?style=flat-square)](https://github.com/php-http/stopwatch-plugin/releases) | ||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) | ||
[![Build Status](https://img.shields.io/travis/php-http/stopwatch-plugin.svg?style=flat-square)](https://travis-ci.org/php-http/stopwatch-plugin) | ||
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/stopwatch-plugin.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/stopwatch-plugin) | ||
[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/stopwatch-plugin.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/stopwatch-plugin) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/stopwatch-plugin.svg?style=flat-square)](https://packagist.org/packages/php-http/stopwatch-plugin) | ||
|
||
**Symfony Stopwatch plugin for HTTPlug.** | ||
|
||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` bash | ||
$ composer require php-http/stopwatch-plugin | ||
``` | ||
|
||
|
||
## Documentation | ||
|
||
Please see the [official documentation](http://docs.php-http.org/en/latest/plugins/stopwatch.html). | ||
|
||
|
||
## Testing | ||
|
||
``` bash | ||
$ composer test | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). | ||
|
||
|
||
## Security | ||
|
||
If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). | ||
|
||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "php-http/stopwatch-plugin", | ||
"description": "Symfony Stopwatch plugin for HTTPlug", | ||
"license": "MIT", | ||
"keywords": ["stopwatch", "http", "httplug", "plugin"], | ||
"homepage": "http://httplug.io", | ||
"authors": [ | ||
{ | ||
"name": "Márk Sági-Kazár", | ||
"email": "mark.sagikazar@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4", | ||
"symfony/stopwatch": "^2.3", | ||
"php-http/client-common": "^1.1" | ||
}, | ||
"require-dev": { | ||
"phpspec/phpspec": "^2.5", | ||
"henrikbjorn/phpspec-code-coverage" : "^1.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Http\\Client\\Common\\Plugin\\": "src/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpspec run", | ||
"test-ci": "vendor/bin/phpspec run -c phpspec.yml.ci" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
} | ||
}, | ||
"prefer-stable": true, | ||
"minimum-stability": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
suites: | ||
stopwatch_plugin_suite: | ||
namespace: Http\Client\Common\Plugin | ||
psr4_prefix: Http\Client\Common\Plugin | ||
formatter.name: pretty | ||
extensions: | ||
- PhpSpec\Extension\CodeCoverageExtension | ||
code_coverage: | ||
format: clover | ||
output: build/coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
suites: | ||
stopwatch_plugin_suite: | ||
namespace: Http\Client\Common\Plugin | ||
psr4_prefix: Http\Client\Common\Plugin | ||
formatter.name: pretty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace spec\Http\Client\Common\Plugin; | ||
|
||
use Http\Client\Exception\NetworkException; | ||
use Http\Promise\FulfilledPromise; | ||
use Http\Promise\RejectedPromise; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Symfony\Component\Stopwatch\Stopwatch; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class StopwatchPluginSpec extends ObjectBehavior | ||
{ | ||
function let(Stopwatch $stopwatch) | ||
{ | ||
$this->beConstructedWith($stopwatch); | ||
} | ||
|
||
function it_is_initializable(Stopwatch $stopwatch) | ||
{ | ||
$this->shouldHaveType('Http\Client\Common\Plugin\StopwatchPlugin'); | ||
} | ||
|
||
function it_is_a_plugin() | ||
{ | ||
$this->shouldImplement('Http\Client\Common\Plugin'); | ||
} | ||
|
||
function it_records_event(Stopwatch $stopwatch, RequestInterface $request, ResponseInterface $response) | ||
{ | ||
$request->getMethod()->willReturn('GET'); | ||
$request->getRequestTarget()->willReturn('/'); | ||
|
||
$stopwatch->start('GET /', 'php_http.request')->shouldBeCalled(); | ||
$stopwatch->stop('GET /', 'php_http.request')->shouldBeCalled(); | ||
|
||
$next = function (RequestInterface $request) use ($response) { | ||
return new FulfilledPromise($response->getWrappedObject()); | ||
}; | ||
|
||
$this->handleRequest($request, $next, function () {}); | ||
} | ||
|
||
function it_records_event_on_error(Stopwatch $stopwatch, RequestInterface $request) | ||
{ | ||
$request->getMethod()->willReturn('GET'); | ||
$request->getRequestTarget()->willReturn('/'); | ||
|
||
$stopwatch->start('GET /', 'php_http.request')->shouldBeCalled(); | ||
$stopwatch->stop('GET /', 'php_http.request')->shouldBeCalled(); | ||
|
||
$next = function (RequestInterface $request) { | ||
return new RejectedPromise(new NetworkException('', $request)); | ||
}; | ||
|
||
$this->handleRequest($request, $next, function () {}); | ||
} | ||
} |
Oops, something went wrong.