Skip to content

Commit

Permalink
Switch to Chadicus coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
chadicus committed Oct 8, 2016
1 parent af23b8e commit 62639f9
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 61 deletions.
20 changes: 10 additions & 10 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ filter:
excluded_paths:
- 'vendor/*'
- 'tests/*'
- 'examples/*'
before_commands:
- 'composer install --prefer-source'
checks:
php:
custom_coding_standard:
git_repository: 'https://github.com/chadicus/coding-standard'
git_version: '971fac1625463a72df0034fbfdd263561f2ccb4f'
ruleset_path: 'Chadicus/ruleset.xml'
tools:
php_analyzer: true
php_mess_detector: true
php_code_sniffer:
config:
standard: PSR2
sensiolabs_security_checker: true
php_loc:
excluded_dirs:
- vendor
- tests
- examples
php_pdepend: true
php_sim: true
build_failure_conditions:
- 'elements.rating(<= D).new.exists' # No new classes/methods with a rating of D or worse allowed (useful for legacy code)
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
- 'issues.label("coding-style").new.count > 5' # More than 5 new coding style issues.
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric("scrutinizer.quality", < 6)' # Code Quality Rating drops below 6
- 'elements.rating(<= C).new.exists'
- 'issues.label("coding-style").new.exists'
- 'issues.severity(>= MAJOR).new.exists'
- 'project.metric("scrutinizer.quality", < 6)'
17 changes: 11 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
## Questions and Bug Reports
# Contribution Guidelines
You are welcome to report [issues](/../../issues) or submit [pull requests](/../../pulls). While the below guidelines are necessary to get code merged, you can submit pull requests that do not adhere to them and I will try to take care of them in my spare time. If you can make sure the build is passing 100%, that would be very useful.

Submit via [GitHub Issues](https://github.com/chadicus/marvel-api-client/issues)
I recommend including details of your particular usecase(s) with any issues or pull requests.

## Pull Requests
## Questions and Bug Reports
Submit via [GitHub Issues](/../../issues).

Code changes should be sent through [GitHub Pull Requests](https://github.com/chadicus/marvel-api-client/pulls). Before submitting the pull request, make sure that phpunit reports success:
## Pull Requests
Code changes should be sent through [GitHub Pull Requests](/../../pulls). Before submitting the pull request, make sure that phpunit reports success:

```sh
./vendor/bin/phpunit --coverage-html coverage
```

This build enforces 100% [PHPUnit](http://www.phpunit.de) code coverage and 0 errors for the [coding standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
While the build does not enforce 100% [PHPUnit](http://www.phpunit.de) code coverage, it will not allow coverage to drop below its current percentage.

The build will also not allow any errors for the [coding standard](http://chadicus.github.io/coding-standard/)

```sh
./vendor/bin/phpcs --standard=PSR2 src tests
./vendor/bin/phpcs --standard=./vendor/chadicus/coding-standard/Chadicus src tests
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require-dev": {
"phpunit/phpunit": "^5.5",
"satooshi/php-coveralls": "^1.0",
"squizlabs/php_codesniffer": "^2.0",
"chadicus/coding-standard": "^1.1",
"chadicus/test-helpers": "^1.0",
"mongodb/mongodb": "^1.0"
},
Expand Down
41 changes: 39 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Chadicus\Marvel\Api\Adapter;

use Chadicus\Marvel\Api;
use Chadicus\Marvel\Api\RequestInterface;

/**
* Simple interface for a client adapter.
Expand All @@ -14,7 +14,7 @@ interface AdapterInterface
*
* @param RequestInterface $request The request to send.
*
* @return Api\ResponseInterface
* @return \Chadicus\Marvel\Api\ResponseInterface
*/
public function send(Api\RequestInterface $request);
public function send(RequestInterface $request);
}
15 changes: 9 additions & 6 deletions src/Cache/AbstractCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Chadicus\Marvel\Api\Cache;

/**
* Base class for all cache objects.
*/
abstract class AbstractCache implements CacheInterface
{
/**
Expand All @@ -14,7 +17,7 @@ abstract class AbstractCache implements CacheInterface
/**
* Sets the default time to live in seconds.
*
* @param integer $defaultTimeToLive The time in seconds
* @param integer $defaultTimeToLive The time in seconds.
*
* @return void
*/
Expand All @@ -26,21 +29,21 @@ final public function setDefaultTTL($defaultTimeToLive)
/**
* Returns the default time to live in seconds.
*
* @return integer The time in seconds
* @return integer The time in seconds.
*/
final public function getDefaultTTL()
{
return $this->defaultTimeToLive;
}

/**
* Helper method to check TTL value
* Helper method to check TTL value.
*
* @param integer $ttl The time value to check in seconds
* @param integer $ttl The time value to check in seconds.
*
* @return integer The valid $ttl value
* @return integer The valid $ttl value.
*
* @throws \InvalidArgumentException Thrown if $ttl is < 1 or > CacheInterface::MAX_TTL
* @throws \InvalidArgumentException Thrown if $ttl is < 1 or > CacheInterface::MAX_TTL.
*/
final protected static function ensureTTL($ttl)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/MongoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(Collection $collection, $defaultTimeToLive = CacheIn
*
* @param RequestInterface $request The request for which the response will be cached.
* @param ResponseInterface $response The reponse to cache.
* @param integer $timeToLive The time in seconds that the cache should live.
* @param integer $timeToLive The time in seconds that the cache should live.
*
* @return void
*
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ final private function getFromCache(RequestInterface $request)
/**
* Allow calls such as $client->characters();
*
* @param string $name The name of the api resource
* @param array $arguments The parameters to pass to get() or search()
* @param string $name The name of the api resource.
* @param array $arguments The parameters to pass to get() or search().
*
* @return Collection|EntityInterface
*/
Expand Down
7 changes: 5 additions & 2 deletions src/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use DominionEnterprises\Util;

/**
* Object representation of the API result data container.
*/
class DataContainer implements DataContainerInterface
{
/**
Expand Down Expand Up @@ -44,7 +47,7 @@ class DataContainer implements DataContainerInterface
/**
* Create a new DataContainer instance.
*
* @param array $input The data for the DataContainer
* @param array $input The data for the DataContainer.
*/
public function __construct(array $input)
{
Expand All @@ -69,7 +72,7 @@ public function __construct(array $input)
/**
* Helper method to derive the filter to use for the given resource array
*
* @param mixed $results the results array from the API
* @param mixed $results The results array from the API.
*
* @return callable The filter to use
*/
Expand Down
3 changes: 3 additions & 0 deletions src/DataContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Chadicus\Marvel\Api;

/**
* Interface for api data container which displays pagination information and an array of results returned by an API call.
*/
interface DataContainerInterface
{

Expand Down
5 changes: 4 additions & 1 deletion src/DataWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use DominionEnterprises\Util;

/**
* Object representation of the API result data wrapper.
*/
class DataWrapper implements DataWrapperInterface
{
/**
Expand Down Expand Up @@ -58,7 +61,7 @@ class DataWrapper implements DataWrapperInterface
/**
* Create a new DataWrapper instance.
*
* @param array $input The data for the DataWrapper
* @param array $input The data for the DataWrapper.
*/
public function __construct(array $input)
{
Expand Down
3 changes: 3 additions & 0 deletions src/DataWrapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Chadicus\Marvel\Api;

/**
* Interface for an API data wrapper which contains metadata about the call and a container object,
*/
interface DataWrapperInterface
{
/**
Expand Down
25 changes: 17 additions & 8 deletions src/Entities/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Chadicus\Spl\Exceptions\NotAllowedException;
use DominionEnterprises\Util;

/**
* Base entity class.
*/
abstract class AbstractEntity implements EntityInterface, \ArrayAccess
{
/**
Expand All @@ -17,9 +20,9 @@ abstract class AbstractEntity implements EntityInterface, \ArrayAccess
private $data = [];

/**
* Create a new AbstractEntity based on the given $input array
* Create a new AbstractEntity based on the given $input array.
*
* @param array $input The data for the EntityInterface
* @param array $input The data for the EntityInterface.
*/
public function __construct(array $input = [])
{
Expand All @@ -32,11 +35,13 @@ public function __construct(array $input = [])
}

/**
* Get an AbstractEntity property
* Get an AbstractEntity property.
*
* @param string $name The name of the property
* @param string $name The name of the property.
*
* @return mixed
*
* @throws UndefinedPropertyException Throw if this class does not contain the $name'd property.
*/
final public function __get($name)
{
Expand All @@ -51,12 +56,12 @@ final public function __get($name)
/**
* Allows for getX() method calls.
*
* @param string $name The name of the method being called.
* @param string $name The name of the method being called.
* @param array $arguments The arguments being passed to the method. This parameter is unused.
*
* @return mixed
*
* @throws \BadMethodCallException Thrown if the property being accessed does not exist
* @throws \BadMethodCallException Thrown if the property being accessed does not exist.
*/
final public function __call($name, array $arguments = [])
{
Expand Down Expand Up @@ -97,7 +102,7 @@ final public static function fromArrays(array $inputs)
/**
* Create a new AbstractEntity based on the given $input array
*
* @param array $input The data for the AbstractEntity
* @param array $input The data for the AbstractEntity.
*
* @return AbstractEntity
*/
Expand Down Expand Up @@ -134,9 +139,11 @@ final public function offsetGet($offset)
* Sets the value at the specified index to newval
*
* @param string $offset The index being get.
* @param mixed $value The new value for the index
* @param mixed $value The new value for the index.
*
* @return void
*
* @throws NotAllowedException Ensure this object is immutable.
*/
final public function offsetSet($offset, $value)
{
Expand All @@ -150,6 +157,8 @@ final public function offsetSet($offset, $value)
* @param string $offset The index being unset.
*
* @return void
*
* @throws NotAllowedException Ensure this object is immutable.
*/
final public function offsetUnset($offset)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @property-read ResourceList $stories A resource list of stories in which this character appears.
* @property-read ResourceList $events A resource list of events in which this character appears.
* @property-read ResourceList $series A resource list of series in which this character appears.
*/
*/
class Character extends AbstractEntity
{
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* @property-read ResourceList $stories A resource list containing the stories which feature work by this creator.
* @property-read ResourceList $comics A resource list containing the comics which feature work by this creator.
* @property-read ResourceList $events A resource list containing the events which feature work by this creator.
*/
*/
class Creator extends AbstractEntity
{
/**
* @see AbstractEntity::getFilters()
* @see AbstractEntity::getFilters().
*
* @return array
*/
Expand Down
Loading

0 comments on commit 62639f9

Please # to comment.