Skip to content

Commit 245ba34

Browse files
authored
Merge pull request #58 from codeclimate/pb-psr-4-etc
Added vendor/project namespace, restructured folders for PSR-4
2 parents 9217abf + 63aadd1 commit 245ba34

15 files changed

+203
-157
lines changed

.codeclimate.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
engines:
3+
duplication:
4+
enabled: true
5+
config:
6+
languages:
7+
- php
8+
phpcodesniffer:
9+
enabled: true
10+
phpmd:
11+
enabled: true
12+
checks:
13+
CleanCode/ElseExpression:
14+
enabled: false
15+
Controversial/Superglobals:
16+
enabled: false
17+
exclude_fingerprints:
18+
# High complexity in CiInfo#toArray()
19+
- 8f1ff5077ea52a5fee818bde73a0dbb7
20+
- efc665f3aa41cbbd0bbd0ec9c945a453
21+
ratings:
22+
paths:
23+
- "**.inc"
24+
- "**.module"
25+
- "**.php"
26+
exclude_paths:
27+
- tests/

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
.idea/
2+
.vagrant/
3+
Vagrantfile
14
build/
25
vendor/
3-
box.phar
4-
codeclimate-test-reporter.phar
56
composer.lock
67
composer.phar

.travis.yml

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ cache:
99
directories:
1010
- $HOME/.composer/cache
1111

12-
env:
13-
global:
14-
secure: Yc+Xohkr/iEUU7FCQuSLXAE9ywNW9g6CfrM1Ki0Hl+fS15F3AXT7dFY8EyCJ4dP1/oI0dBmwrGWrltXV0XWIjGV1Ms3tefCgQpBBAqwT+hImzVP3RbpZW8Iyo2d0VgiDemQF1LWYD/pKu6d8WljTnv5D77NIMdEJjQ0uzeTLWdw=
15-
1612
before_install:
1713
- composer self-update
1814

composer.json

+29-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "codeclimate/php-test-reporter",
33
"description": "PHP client for reporting test coverage to Code Climate",
4-
"keywords": ["codeclimate", "coverage"],
4+
"keywords": [
5+
"codeclimate",
6+
"coverage"
7+
],
58
"homepage": "https://github.com/codeclimate/php-test-reporter",
69
"type": "library",
710
"license": "MIT",
@@ -15,23 +18,40 @@
1518
"require": {
1619
"php": ">=5.3",
1720
"ext-curl": "*",
18-
"satooshi/php-coveralls": "1.0.*",
19-
"symfony/console": ">=2.0"
21+
"satooshi/php-coveralls": "^1.0",
22+
"symfony/console": "^2.0"
2023
},
2124
"require-dev": {
2225
"phpunit/phpunit": "3.7.*@stable",
23-
"ext-xdebug": "*"
26+
"ext-xdebug": "*",
27+
"tm/tooly-composer-script": "^1.0"
2428
},
2529
"autoload": {
26-
"psr-0": {
27-
"CodeClimate\\Component": "src/",
28-
"CodeClimate\\Bundle": "src/"
30+
"psr-4": {
31+
"CodeClimate\\PhpTestReporter\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"CodeClimate\\PhpTestReporter\\Tests\\": "tests/"
2937
}
3038
},
31-
"bin": ["composer/bin/test-reporter"],
39+
"bin": [
40+
"composer/bin/test-reporter"
41+
],
42+
"scripts": {
43+
"post-install-cmd": "Tooly\\ScriptHandler::installPharTools",
44+
"post-update-cmd": "Tooly\\ScriptHandler::installPharTools"
45+
},
3246
"extra": {
3347
"branch-alias": {
3448
"dev-master": "0.3.x-dev"
35-
}
49+
},
50+
"tools": {
51+
"box": {
52+
"url": "https://github.com/box-project/box2/releases/download/2.7.2/box-2.7.2.phar",
53+
"only-dev": true
54+
}
55+
}
3656
}
3757
}

composer/bin/test-reporter

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$files = array(
4+
namespace CodeClimate\PhpTestReporter;
5+
6+
use CodeClimate\PhpTestReporter\Constants\Version;
7+
8+
$files = [
59
__DIR__ . '/../../vendor/autoload.php',
6-
__DIR__ . '/../../../../autoload.php'
7-
);
10+
__DIR__ . '/../../../../autoload.php',
11+
];
812

913
foreach ($files as $file) {
1014
if (file_exists($file)) {
@@ -24,9 +28,6 @@ if (!defined('PHP_TEST_REPORTER_COMPOSER_INSTALL')) {
2428
);
2529
}
2630

27-
use CodeClimate\Bundle\TestReporterBundle\Version;
28-
use CodeClimate\Bundle\TestReporterBundle\Console\Application;
29-
3031
$rootDir = realpath(dirname(PHP_TEST_REPORTER_COMPOSER_INSTALL) . '/..');
3132

3233
$app = new Application($rootDir, 'Code Climate PHP Test Reporter', Version::VERSION);
+4-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
<?php
2-
namespace CodeClimate\Bundle\TestReporterBundle\Console;
2+
namespace CodeClimate\PhpTestReporter;
33

4-
use CodeClimate\Bundle\TestReporterBundle\Command\TestReporterCommand;
4+
use CodeClimate\PhpTestReporter\ConsoleCommands\TestReporterCommand;
55
use Symfony\Component\Console\Application as BaseApplication;
66
use Symfony\Component\Console\Input\InputInterface;
77

88
/**
99
* Coveralls API application.
10-
*
1110
* @author Kitamura Satoshi <[email protected]>
1211
*/
1312
class Application extends BaseApplication
1413
{
1514
/**
1615
* Path to project root directory.
17-
*
1816
* @var string
1917
*/
2018
private $rootDir;
@@ -37,7 +35,6 @@ public function __construct($rootDir, $name = 'UNKNOWN', $version = 'UNKNOWN')
3735

3836
/**
3937
* {@inheritdoc}
40-
*
4138
* @see \Symfony\Component\Console\Application::getCommandName()
4239
*/
4340
protected function getCommandName(InputInterface $input)
@@ -47,23 +44,21 @@ protected function getCommandName(InputInterface $input)
4744

4845
/**
4946
* {@inheritdoc}
50-
*
5147
* @see \Symfony\Component\Console\Application::getDefaultCommands()
5248
*/
5349
protected function getDefaultCommands()
5450
{
5551
// Keep the core default commands to have the HelpCommand
5652
// which is used when using the --help option
57-
$defaultCommands = parent::getDefaultCommands();
53+
$defaultCommands = parent::getDefaultCommands();
5854
$defaultCommands[] = $this->createTestReporterCommand();
5955

6056
return $defaultCommands;
6157
}
6258

6359
/**
6460
* Create TestReporterCommand.
65-
*
66-
* @return \CodeClimate\Bundle\TestReporterBundle\Command\TestReporterCommand
61+
* @return TestReporterCommand
6762
*/
6863
protected function createTestReporterCommand()
6964
{
@@ -77,7 +72,6 @@ protected function createTestReporterCommand()
7772

7873
/**
7974
* {@inheritdoc}
80-
*
8175
* @see \Symfony\Component\Console\Application::getDefinition()
8276
*/
8377
public function getDefinition()
+23-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2-
namespace CodeClimate\Bundle\TestReporterBundle\Command;
32

4-
use CodeClimate\Bundle\TestReporterBundle\CoverageCollector;
5-
use CodeClimate\Bundle\TestReporterBundle\ApiClient;
3+
namespace CodeClimate\PhpTestReporter\ConsoleCommands;
4+
5+
use CodeClimate\PhpTestReporter\TestReporter\ApiClient;
6+
use CodeClimate\PhpTestReporter\TestReporter\CoverageCollector;
67
use Symfony\Component\Console\Command\Command;
78
use Symfony\Component\Console\Input\InputInterface;
89
use Symfony\Component\Console\Input\InputOption;
@@ -15,51 +16,48 @@ class TestReporterCommand extends Command
1516
{
1617
/**
1718
* Path to project root directory.
18-
*
1919
* @var string
2020
*/
2121
protected $rootDir;
2222

2323
/**
2424
* {@inheritdoc}
25-
*
2625
* @see \Symfony\Component\Console\Command\Command::configure()
2726
*/
2827
protected function configure()
2928
{
3029
$this
31-
->setName('test-reporter')
32-
->setDescription('Code Climate PHP Test Reporter')
33-
->addOption(
34-
'stdout',
35-
null,
36-
InputOption::VALUE_NONE,
37-
'Do not upload, print JSON payload to stdout'
38-
)
39-
->addOption(
40-
'coverage-report',
41-
null,
42-
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
43-
'Location of clover style CodeCoverage report, as produced by PHPUnit\'s --coverage-clover option.',
44-
array('build/logs/clover.xml')
45-
);
30+
->setName('test-reporter')
31+
->setDescription('Code Climate PHP Test Reporter')
32+
->addOption(
33+
'stdout',
34+
null,
35+
InputOption::VALUE_NONE,
36+
'Do not upload, print JSON payload to stdout'
37+
)
38+
->addOption(
39+
'coverage-report',
40+
null,
41+
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
42+
'Location of clover style CodeCoverage report, as produced by PHPUnit\'s --coverage-clover option.',
43+
[ 'build/logs/clover.xml' ]
44+
);
4645
}
4746

4847
/**
4948
* {@inheritdoc}
50-
*
5149
* @see \Symfony\Component\Console\Command\Command::execute()
5250
*/
5351
protected function execute(InputInterface $input, OutputInterface $output)
5452
{
55-
$ret = 0;
53+
$ret = 0;
5654
$collector = new CoverageCollector($input->getOption('coverage-report'));
57-
$json = $collector->collectAsJson();
55+
$json = $collector->collectAsJson();
5856

5957
if ($input->getOption('stdout')) {
6058
$output->writeln((string)$json);
6159
} else {
62-
$client = new ApiClient();
60+
$client = new ApiClient();
6361
$response = $client->send($json);
6462
switch ($response->code) {
6563
case 200:
@@ -72,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7270
break;
7371

7472
default:
75-
$output->writeln("Unexpected response: ".$response->code." ".$response->message);
73+
$output->writeln("Unexpected response: " . $response->code . " " . $response->message);
7674
$output->writeln($response->body);
7775
$ret = 1;
7876
break;

src/CodeClimate/Bundle/TestReporterBundle/Version.php renamed to src/Constants/Version.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
namespace CodeClimate\Bundle\TestReporterBundle;
2+
3+
namespace CodeClimate\PhpTestReporter\Constants;
34

45
/**
56
* TestReporterBundle version.

src/CodeClimate/Component/System/Git/GitCommand.php renamed to src/System/Git/GitCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace CodeClimate\Component\System\Git;
2+
namespace CodeClimate\PhpTestReporter\System\Git;
33

44
use Satooshi\Component\System\SystemCommand;
55

0 commit comments

Comments
 (0)