Skip to content

Commit 4607674

Browse files
committed
CS.
1 parent a2d096f commit 4607674

File tree

3 files changed

+52
-25
lines changed

3 files changed

+52
-25
lines changed

.php_cs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
<?php
2-
$header = <<<EOF
3-
This file is part of the overtrue/laravel-query-logger.
4-
5-
(c) overtrue <i@overtrue.me>
6-
7-
This source file is subject to the MIT license that is bundled
8-
with this source code in the file LICENSE.
9-
EOF;
10-
112
return PhpCsFixer\Config::create()
12-
->setRiskyAllowed(true)
13-
->setRules(array(
14-
'@Symfony' => true,
15-
'header_comment' => array('header' => $header),
16-
'array_syntax' => array('syntax' => 'short'),
17-
'ordered_imports' => true,
18-
'no_useless_else' => true,
19-
'no_useless_return' => true,
20-
'php_unit_construct' => true,
21-
'php_unit_strict' => true,
22-
))
3+
->setRules([
4+
'@PSR2' => true,
5+
'array_syntax' => ['syntax' => 'short'],
6+
'blank_line_after_opening_tag' => true,
7+
'braces' => ['allow_single_line_closure' => true],
8+
'compact_nullable_typehint' => true,
9+
'concat_space' => ['spacing' => 'one'],
10+
'declare_equal_normalize' => ['space' => 'none'],
11+
'function_typehint_space' => true,
12+
'new_with_braces' => true,
13+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
14+
'no_empty_statement' => true,
15+
'no_leading_import_slash' => true,
16+
'no_leading_namespace_whitespace' => true,
17+
'no_whitespace_in_blank_line' => true,
18+
'return_type_declaration' => ['space_before' => 'none'],
19+
'single_trait_insert_per_statement' => true,
20+
])
2321
->setFinder(
2422
PhpCsFixer\Finder::create()
2523
->exclude('vendor')
26-
->in(__DIR__)
24+
->in([__DIR__.'/src/'])
2725
)
28-
;
26+
;

composer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@
2020
"extra": {
2121
"laravel": {
2222
"providers": ["Overtrue\\LaravelQueryLogger\\ServiceProvider"]
23+
},
24+
"hooks": {
25+
"pre-commit": [
26+
"composer test",
27+
"composer fix-style"
28+
],
29+
"pre-push": [
30+
"composer test",
31+
"composer check-style"
32+
]
2333
}
34+
},
35+
"scripts": {
36+
"post-update-cmd": [
37+
"cghooks update"
38+
],
39+
"post-merge": "composer install",
40+
"post-install-cmd": [
41+
"cghooks add --ignore-lock",
42+
"cghooks update"
43+
],
44+
"cghooks": "vendor/bin/cghooks",
45+
"check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php_cs --dry-run --ansi",
46+
"fix-style": "php-cs-fixer fix --using-cache=no --config=.php_cs --ansi",
47+
"test": "vendor/bin/phpunit --colors=always"
48+
},
49+
"scripts-descriptions": {
50+
"test": "Run all tests.",
51+
"check-style": "Run style checks (only dry run - no fixing!).",
52+
"fix-style": "Run style checks and fix violations."
2453
}
2554
}

src/ServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function register()
6464
private function formatDuration($seconds)
6565
{
6666
if ($seconds < 0.001) {
67-
return round($seconds * 1000000).'μs';
67+
return round($seconds * 1000000) . 'μs';
6868
} elseif ($seconds < 1) {
69-
return round($seconds * 1000, 2).'ms';
69+
return round($seconds * 1000, 2) . 'ms';
7070
}
7171

72-
return round($seconds, 2).'s';
72+
return round($seconds, 2) . 's';
7373
}
7474
}

0 commit comments

Comments
 (0)