Skip to content

Commit

Permalink
Merge pull request #59 from Jeroeny/update
Browse files Browse the repository at this point in the history
Update codestyle, php version, tests, add interface
  • Loading branch information
colinodell authored Jan 15, 2022
2 parents c6290ef + e6fad3c commit b01e4f4
Show file tree
Hide file tree
Showing 35 changed files with 540 additions and 365 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; top-most EditorConfig file
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/tests/ export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push: ~
pull_request: ~

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
tools: composer:v2, cs2pr

- run: composer update --no-progress

- run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

phpunit:
name: PHPUnit on ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ !matrix.stable }}
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1']
stable: [true]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
tools: composer:v2

- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- run: composer update --no-progress

- run: vendor/bin/phpunit --coverage-text
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor
composer.lock
/vendor
/composer.lock
/.phpcs-cache
/.phpunit.result.cache
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

96 changes: 96 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Change Log
All notable changes to this project will be documented in this file.
Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [Unreleased][unreleased]
### Added
- Added new `StatsDClient` interface, which `Client` now implements
- Added new `Exception` interface, which all exceptions now implement

### Changed
- Supported PHP versions are now 7.4, 8.0, and 8.1
- All properties and methods now have type hints where applicable
- The following methods return the `StatsDClient` interface instead of `Client`:
- `ConfigurationException::getInstance()`
- `ConnectionException::getInstance()`
- The following `Client` methods now return `void` instead of returning `$this`:
- `increment()`
- `decrement()`
- `startTiming()`
- `endTiming()`
- `timing()`
- `timings()`
- `time()`
- `gauge()`
- `set()`
- `send()`
- Renamed `Client::$instance_id` to `Client::$instanceId`

## [1.5.0] - 2018-10-09
### Added
- Added tags supporting Datadog format (#52)

## [1.4.3] - 2017-07-17
### Added
- Added Silex 2 support (#43)

### Changed
- Dropped support for PHP <5.6
- Test against PHP 7.1

## [1.4.2] - 2017-02-09
### Changed
- Use `config` to allow publishing differently to views or assets within Laravel

## [1.4.1] - 2017-02-02
### Added
- Added Laravel 5.4 support

## [1.4.0] - 2016-04-21
### Added
- Custom timeout configurations
- Exception handling is now configurable
- Built-in Laravel 5 support

### Fixed
- DNS lookup failures no longer raise exceptions

## [1.3.0] - 2015-06-11
### Changed
- Throwing an exception is now optional during connections to server and can be silently ignored

## [1.2.0] - 2015-05-15
### Added
- Configurable timeouts
- SET method: Count the number of unique values passed to a key
- PHP 5.6 testing on Travis
- Various test patches and improvements

## [1.1.0] - 2014-02-01
### Added
- PSR-4 support
- New documentation

## [1.0.0] - 2013-08-27

This is the first fully stable version of StatsD library. This version has the following features:

- Counters
- Gauges
- Timers
- Timing Blocks
- 100% Code Coverage
- Silex Service Provider

[unreleased]: https://github.com/thephpleague/statsd/compare/1.5.0...master
[1.5.0]: https://github.com/thephpleague/statsd/compare/1.4.5...1.5.0
[1.4.5]: https://github.com/thephpleague/statsd/compare/1.4.4...1.4.5
[1.4.4]: https://github.com/thephpleague/statsd/compare/1.4.3...1.4.4
[1.4.3]: https://github.com/thephpleague/statsd/compare/1.4.2...1.4.3
[1.4.2]: https://github.com/thephpleague/statsd/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/thephpleague/statsd/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/thephpleague/statsd/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/thephpleague/statsd/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/thephpleague/statsd/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/thephpleague/statsd/compare/v1.0...1.1.0
[1.0.0]: https://github.com/thephpleague/statsd/releases/tag/v1.0
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ To use the Statsd Service Provider, you must register the provider when bootstra

```php
$statsd = new League\StatsD\Client();
$statsd->configure(array(
$statsd->configure([
'host' => '127.0.0.1',
'port' => 8125,
'namespace' => 'example'
));
]);
```

OR

```php
$statsd1 = StatsD\Client::instance('server1')->configure(array(...));
$statsd2 = StatsD\Client::instance('server2')->configure(array(...));
$statsd1 = StatsD\Client::instance('server1')->configure([...]);
$statsd2 = StatsD\Client::instance('server2')->configure([...]);
```

The StatsD client wait for `ini_get('default_socket_timeout')` seconds when opening the socket by default. To reduce
Expand All @@ -65,10 +65,10 @@ If omitted, this option defaults to `true`.
```php
$statsd->increment('web.pageview');
$statsd->decrement('storage.remaining');
$statsd->increment(array(
$statsd->increment([
'first.metric',
'second.metric'
), 2);
], 2);
$statsd->increment('web.clicks', 1, 0.5);
```

Expand Down Expand Up @@ -112,18 +112,18 @@ $statsd->time('api.dbcall', function () {

***Attention!** That functionality support of tags in Datadog format!*

You may configure it for all the metrics sending by the client.
You may configure it for all the metrics sending by the client.

```php
$statsd->configure(array(
'tags' => array('some_general_tag' => 'value')
));
$statsd->configure([
'tags' => ['some_general_tag' => 'value']
]);
```

Or you may send it for a single metric.

```php
$statsd->increment('web.clicks', 1, 1, array('host' => $_SERVER['HTTP_HOST']));
$statsd->increment('web.clicks', 1, 1, ['host' => $_SERVER['HTTP_HOST']]);
```

## Framework integration
Expand All @@ -136,19 +136,19 @@ integrate it quickly with the most popular ones via included adapters.
Find the `providers` key in your `app/config/app.php` and register the Statsd Service Provider.

```php
'providers' => array(
'providers' => [
// ...
'League\StatsD\Laravel\Provider\StatsdServiceProvider',
)
]
```

Find the `aliases` key in your `app/config/app.php` and add the Statsd Facade Alias.

```php
'aliases' => array(
'aliases' => [
// ...
'Statsd' => 'League\StatsD\Laravel\Facade\StatsdFacade',
)
]
```
### Laravel 5.x

Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
"role": "Developer"
}
],
"require": {
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5"
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions docs/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ Creating a new instance within your application is very easy.

```php
$statsd = new League\StatsD\Client();
$statsd->configure(array(
$statsd->configure([
'host' => 'localhost',
'port' => 8125,
'namespace' => 'ns1'
));
]);
```

**Note** The namespace is optional, but recommended.
Expand Down
20 changes: 20 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset
name="PHPCS Coding Standards"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="colors" />
<arg name="cache" value=".phpcs-cache"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<rule ref="PSR12"/>

<file>src</file>
<file>tests</file>

</ruleset>
18 changes: 12 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" bootstrap="vendor/autoload.php">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">

<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>

<testsuites>
<testsuite name="League StatsD Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

</phpunit>
Loading

0 comments on commit b01e4f4

Please sign in to comment.