Skip to content

Commit

Permalink
Coding standard fix
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Sep 7, 2021
1 parent e8a8454 commit 8c62154
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
17 changes: 8 additions & 9 deletions src/Helpers/DateFormatter.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
<?php
<?php declare(strict_types=1);
namespace Imbo\Helpers;

use DateTime;
use DateTimeZone;

/**
* Date formatter helper class
*/
class DateFormatter {
class DateFormatter
{
/**
* Get a formatted date
*
* @param DateTime $date An instance of DateTime
* @return string Returns a formatted date string
*/
public function formatDate(DateTime $date) {
$date->setTimezone(new DateTimeZone('UTC'));

return $date->format('D, d M Y H:i:s') . ' GMT';
public function formatDate(DateTime $date): string
{
return $date
->setTimezone(new DateTimeZone('UTC'))
->format('D, d M Y H:i:s') . ' GMT';
}
}
16 changes: 10 additions & 6 deletions src/Helpers/Imagick.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<?php
<?php declare(strict_types=1);
namespace Imbo\Helpers;

use Imagick as ImagickInternal;

/**
* Helper class for Imagick
*/
class Imagick {
class Imagick
{
/**
* Get the version number (x.y.z-p) of the ImageMagick version installed (not the extension version, but
* the version of ImageMagick it's using). Returns null on failure.
*
* @return string|null
* @return ?string
*/
public static function getInstalledVersion() {
$params = explode(' ', \Imagick::getVersion()['versionString']);
public static function getInstalledVersion(): ?string
{
$params = explode(' ', ImagickInternal::getVersion()['versionString']);

if (count($params) > 2) {
return $params[1];
}

return null;
}
}
}
19 changes: 13 additions & 6 deletions tests/Helpers/DateFormatterTest.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<?php declare(strict_types=1);
namespace Imbo\Helpers;

use PHPUnit\Framework\TestCase;
use DateTime;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\Helpers\DateFormatter
*/
class DateFormatterTest extends TestCase {
private $helper;
class DateFormatterTest extends TestCase
{
private DateFormatter $helper;

public function setUp() : void {
public function setUp(): void
{
$this->helper = new DateFormatter();
}

public function getDates() : array {
/**
* @return array<array{0:DateTime,1:string}>
*/
public function getDates(): array
{
return [
[new DateTime('@1234567890'), 'Fri, 13 Feb 2009 23:31:30 GMT'],
[new DateTime('16/Mar/2012:15:05:00 +0100'), 'Fri, 16 Mar 2012 14:05:00 GMT'],
Expand All @@ -25,7 +31,8 @@ public function getDates() : array {
* @dataProvider getDates
* @covers ::formatDate
*/
public function testCanFormatADateTimeInstance($datetime, $expected) : void {
public function testCanFormatADateTimeInstance(DateTime $datetime, string $expected): void
{
$this->assertSame($expected, $this->helper->formatDate($datetime));
}
}

0 comments on commit 8c62154

Please sign in to comment.