Skip to content

Commit

Permalink
Merge pull request #19 from koriym/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
koriym authored Mar 18, 2018
2 parents 1222885 + 120a648 commit 0c6d9d5
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 231 deletions.
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ return \PhpCsFixer\Config::create()
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'declare_strict_types' => false,
'declare_strict_types' => true,
'dir_constant' => true,
'ereg_to_preg' => true,
'function_typehint_space' => true,
Expand Down
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
language: php
dist: trusty
sudo: false
php:
- 5.6
- 7
- 7.1
- hhvm
- 7.2
cache:
directories:
- vendor
- $HOME/.composer/cache
env:
matrix:
- DEPENDENCIES=""
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DEPENDENCIES=''
- DEPENDENCIES='--prefer-lowest --prefer-stable'
before_script:
- composer self-update
- composer update $DEPENDENCIES
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then COVERAGE="--coverage-clover=coverage.clover"; else phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then composer require --dev phpstan/phpstan-shim friendsofphp/php-cs-fixer; fi
script:
- ./vendor/bin/phpunit --coverage-clover=coverage.clover;
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php php-cs-fixer-v2.phar fix --config=.php_cs -v --dry-run --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE`; fi

- ./vendor/bin/phpunit $COVERAGE;
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS && ./vendor/bin/php-cs-fixer fix --config=.php_cs -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}";fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' && DEPENDENCIES = '' ]]; then ./vendor/bin/phpstan analyse -l max -c phpstan.neon src tests --no-progress --no-interaction; fi
after_script:
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Akihito Koriyama
Copyright (c) 2015-2018 Akihito Koriyama

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@
[![Code Coverage](https://scrutinizer-ci.com/g/bearsunday/BEAR.AppMeta/badges/coverage.png?b=1.x)](https://scrutinizer-ci.com/g/bearsunday/BEAR.AppMeta/?branch=1.x)
[![Build Status](https://travis-ci.org/bearsunday/BEAR.AppMeta.svg?branch=1.x)](https://travis-ci.org/bearsunday/BEAR.AppMeta)

BEAR.Sunday application meta information object
Application meta data value object

* AppMeta object keep the application path such as $tmpDir, $logDi and $appDir in public property by given app name and context.

* `getResourceListGenerator()` return `\Generator` to get resource class name and paths.


```php
use BEAR\AppMeta\AppMeta;

$appMeta = new AppMeta('MyVendor\HelloWorld');

// provids directory path

// $appMeta->name; // MyVendor\HelloWorld
// $appMeta->appDir; // MyVendor\HelloWorld/src
// $appMeta->logDir; // MyVendor\HelloWorld/var/log
// $appMeta->tmpDir; // MyVendor\HelloWorld/var/tmp

// resource class / list generator

foreach ($appMeta->getResourceListGenerator() as list($class, $file)) {
var_dump($class); // FakeVendor\HelloWorld\Resource\App\Greeting
var_dump($file); // path/to/Greeting.php
}
```
## Requirements

* bear/package ~1.0
175 changes: 0 additions & 175 deletions build.xml

This file was deleted.

16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"BEAR.Sunday"
],
"license": "MIT",
"require": {
"php": ">=7.0.0",
"koriym/psr4list": "^1.0"
},
"autoload":{
"psr-4":{
"BEAR\\AppMeta\\": "src/"
Expand All @@ -13,18 +17,16 @@
"autoload-dev":{
"psr-4":{
"BEAR\\AppMeta\\": ["tests/", "tests/Fake"],
"FakeVendor\\HelloWorld\\": "tests/Fake/fake-app/src"
"FakeVendor\\HelloWorld\\": "tests/Fake/fake-app/src",
"FakeVendor\\NotWritable\\": "tests/Fake/fake-not-writable/src"
}
},
"require": {
"koriym/psr4list": "~1.0"
},
"require-dev": {
"bear/resource": "~1.0",
"phpunit/phpunit": "^5.7 || ^6.0"
"bear/resource": "^1.0",
"phpunit/phpunit": "^6.0"
},
"scripts" :{
"test": ["@cs", "phpunit"],
"test": ["@cs", "phpunit", "phpstan analyse -l max src tests -c phpstan.neon --no-progress"],
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"],
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"]
Expand Down
Empty file added phpstan.neon
Empty file.
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite>
<directory suffix="Test.php">tests</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 3 additions & 1 deletion src/AbstractAppMeta.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* This file is part of the BEAR.AppMeta package.
*
Expand All @@ -11,7 +13,7 @@
abstract class AbstractAppMeta
{
/**
* Application name "{Vendor}\{Package}"
* Application name "{Vendor}\{Project}"
*
* @var string
*/
Expand Down
Loading

0 comments on commit 0c6d9d5

Please sign in to comment.