Skip to content

Commit

Permalink
Implement PSR-12 (mostly).
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyamcl committed Mar 30, 2020
1 parent 606fa16 commit da26a45
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 15 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v3.1.1] - 2020-03-30
### Changed
- Implement PSR-12 (require `squizlabs/php_codesniffer: "^3.5"` in `composer.json`)

### Fixed
- Fix compatibility with PHP 7.4 by removing curly bracket usage (thanks @danez)

## [v3.1] - 2019-12-14
### Added
- Support for Symfony v5 in `composer.json`
Expand All @@ -17,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [v3.0] - 2018-10-15
### Changed
- Upgraded from PSR-0 to PSR-4
- Require PHP5.5 or newer (hint: upgrade to PHP7, since PHP5 support is [being deprecated](http://php.net/supported-versions.php))
- Require PHP5.5 or newer (hint: upgrade to PHP7, since PHP5 support is [~being~ deprecated](http://php.net/supported-versions.php))
- Change all `DateTime` references and type-hints to `DateTimeInterface`
- Renamed `httpClient` variables and proprties to `httpAdapter` for consistency in naming
- Improved README and documentation
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ PHPOAIPMH

## A PHP OAI-PMH harvester client library


[![Latest Version](https://img.shields.io/github/release/caseyamcl/phpoaipmh.svg?style=flat-square?style=flat-square)](https://github.com/caseyamcl/phpoaipmh/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://travis-ci.org/caseyamcl/Phpoiapmh.png)](https://travis-ci.org/caseyamcl/Phpoiapmh.png)
Expand All @@ -14,7 +13,7 @@ This library provides an interface to harvest OAI-PMH metadata
from any [OAI 2.0 compliant endpoint](http://www.openarchives.org/OAI/openarchivesprotocol.html#ListMetadataFormats).

Features:
* PSR-0 thru PSR-2 Compliant
* PSR-12 Compliant
* Composer-compatible
* Unit-tested
* Prefers Guzzle (v6 or v5)for HTTP transport layer, but can fall back to cURL, or implement your own
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require-dev": {
"guzzlehttp/guzzle": "^6.0",
"phpunit/phpunit": "^4.0",
"squizlabs/php_codesniffer": "^3.3",
"squizlabs/php_codesniffer": "^3.5",
"mockery/mockery": "^0.9",
"symfony/console": "^3.4|^4.3|^5.0",
"symfony/dependency-injection": "^3.4.26|^4.3|^5.0",
Expand All @@ -36,7 +36,7 @@
"scripts": {
"test": "phpunit",
"quicktest": "phpunit --no-coverage",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
"check-style": "phpcs -p --standard=PSR12 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR12 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
}
}
7 changes: 5 additions & 2 deletions src/Granularity.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace Phpoaipmh;

use DateTimeInterface;

/**
* PHPOAIPMH Library
*
Expand Down Expand Up @@ -29,12 +32,12 @@ class Granularity
/**
* Format DateTime string based on granularity
*
* @param \DateTimeInterface $dateTime
* @param DateTimeInterface $dateTime
* @param string $format Either self::DATE or self::DATE_AND_TIME
*
* @return string
*/
public static function formatDate(\DateTimeInterface $dateTime, $format)
public static function formatDate(DateTimeInterface $dateTime, $format)
{
$phpFormats = array(
self::DATE => "Y-m-d",
Expand Down
12 changes: 6 additions & 6 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClientTest extends PHPUnit_Framework_TestCase
*/
public function testInstantiateCreatesNewObject()
{
$obj = new Client('http://example.com/oai', new HttpMockClient);
$obj = new Client('http://example.com/oai', new HttpMockClient());
$this->assertInstanceOf('Phpoaipmh\Client', $obj);
}

Expand All @@ -52,7 +52,7 @@ public function testInstantiateCreatesNewObjectWhenNoConstructorArgsPassed()

public function testGetAdapterReturnsHttpAdapterInstance()
{
$obj = new Client('http://example.com/oai', new HttpMockClient);
$obj = new Client('http://example.com/oai', new HttpMockClient());
$this->assertInstanceOf(HttpAdapterInterface::class, $obj->getHttpAdapter());
}

Expand All @@ -62,7 +62,7 @@ public function testGetAdapterReturnsHttpAdapterInstance()
*/
public function testRequestUrlBuildCorrectly($endpointUrl, $expectedRequestUrl)
{
$mockClient = new HttpMockClient;
$mockClient = new HttpMockClient();
$mockClient->toReturn = file_get_contents(__DIR__ . '/SampleXML/GoodResponseIdentify.xml');
$obj = new Client($endpointUrl, $mockClient);
$obj->request('Identify', array('param' => 'value'));
Expand All @@ -83,7 +83,7 @@ public function getUrlsToTest()
*/
public function testRequestDecodesValidResponseCorrectly()
{
$mockClient = new HttpMockClient;
$mockClient = new HttpMockClient();
$mockClient->toReturn = file_get_contents(__DIR__ . '/SampleXML/GoodResponseIdentify.xml');
$obj = new Client('http://nsdl.org/oai', $mockClient);
$result = $obj->request('Identify');
Expand All @@ -98,7 +98,7 @@ public function testRequestDecodesValidResponseCorrectly()
*/
public function testInvalidXMLResponseThrowsHttpRequestException()
{
$mockClient = new HttpMockClient;
$mockClient = new HttpMockClient();
$mockClient->toReturn = 'thisIs&NotXML!!';
$this->setExpectedException('Phpoaipmh\Exception\MalformedResponseException');

Expand All @@ -111,7 +111,7 @@ public function testInvalidXMLResponseThrowsHttpRequestException()
*/
public function testRequestThrowsOAIPMHExceptionForInvalidVerbOrParams()
{
$mockClient = new HttpMockClient;
$mockClient = new HttpMockClient();
$mockClient->toReturn = file_get_contents(__DIR__ . '/SampleXML/BadResponseNonExistentVerb.xml');
$this->setExpectedException('Phpoaipmh\Exception\OaipmhException');

Expand Down
5 changes: 4 additions & 1 deletion tests/Exception/OaipmhExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* phpoaipmh
*
Expand All @@ -16,7 +17,9 @@

namespace Phpoaipmh\Exception;

class OaipmhExceptionTest extends \PHPUnit_Framework_TestCase
use PHPUnit_Framework_TestCase;

class OaipmhExceptionTest extends PHPUnit_Framework_TestCase
{
public function testToStringReturnsExpectedValue()
{
Expand Down
1 change: 1 addition & 0 deletions tests/Fixture/HttpMockClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* phpoaipmh
*
Expand Down

0 comments on commit da26a45

Please sign in to comment.