Skip to content

Commit

Permalink
Fix: Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 2, 2020
1 parent 5296fec commit 1f5b17b
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .php_cs
Expand Up @@ -14,8 +14,8 @@ declare(strict_types=1);
use Ergebnis\PhpCsFixer\Config;

$header = Config\License\Header::create(
Config\License\CopyrightYears::fromYear(Config\License\Year::fromString('2019')),
Config\License\Author::fromString('Andreas Möller'),
Config\License\Copyright\Years::fromYear(Config\License\Copyright\Year::fromString('2019')),
Config\License\Copyright\Holder::fromString('Andreas Möller'),
Config\License\Notice::fromString(
<<<'EOF'
For the full copyright and license information, please view
Expand Down
4 changes: 2 additions & 2 deletions src/License/Author.php → src/License/Copyright/Holder.php
Expand Up @@ -11,12 +11,12 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\License;
namespace Ergebnis\PhpCsFixer\Config\License\Copyright;

/**
* @internal
*/
final class Author
final class Holder
{
private $value;

Expand Down
2 changes: 1 addition & 1 deletion src/License/Year.php → src/License/Copyright/Year.php
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\License;
namespace Ergebnis\PhpCsFixer\Config\License\Copyright;

/**
* @internal
Expand Down
24 changes: 12 additions & 12 deletions src/License/CopyrightYears.php → src/License/Copyright/Years.php
Expand Up @@ -11,12 +11,12 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\License;
namespace Ergebnis\PhpCsFixer\Config\License\Copyright;

/**
* @internal
*/
final class CopyrightYears
final class Years
{
private $value;

Expand All @@ -26,31 +26,31 @@ private function __construct(string $value)
}

/**
* @param Year $startYear
* @param Year $endYear
* @param Year $start
* @param Year $end
*
* @throws \InvalidArgumentException
*
* @return self
*/
public static function fromRange(Year $startYear, Year $endYear): self
public static function fromRange(Year $start, Year $end): self
{
if ($startYear->greaterThan($endYear)) {
if ($start->greaterThan($end)) {
throw new \InvalidArgumentException(\sprintf(
'Start year "%s" needs to be equal to or less than end year "%s".',
$startYear->toString(),
$endYear->toString()
$start->toString(),
$end->toString()
));
}

if ($startYear->equals($endYear)) {
return self::fromYear($startYear);
if ($start->equals($end)) {
return self::fromYear($start);
}

return new self(\sprintf(
'%s-%s',
$startYear->toString(),
$endYear->toString()
$start->toString(),
$end->toString()
));
}

Expand Down
20 changes: 10 additions & 10 deletions src/License/Header.php
Expand Up @@ -18,27 +18,27 @@
*/
final class Header
{
private $copyrightYears;
private $years;

private $author;
private $holder;

private $notice;

private $url;

private function __construct(CopyrightYears $copyrightYears, Author $author, Notice $notice, Url $url)
private function __construct(Copyright\Years $years, Copyright\Holder $holder, Notice $notice, Url $url)
{
$this->copyrightYears = $copyrightYears;
$this->author = $author;
$this->years = $years;
$this->holder = $holder;
$this->notice = $notice;
$this->url = $url;
}

public static function create(CopyrightYears $copyrightYears, Author $author, Notice $notice, Url $url): self
public static function create(Copyright\Years $years, Copyright\Holder $holder, Notice $notice, Url $url): self
{
return new self(
$copyrightYears,
$author,
$years,
$holder,
$notice,
$url
);
Expand All @@ -48,14 +48,14 @@ public function toString(): string
{
if ($this->notice->isEmpty()) {
return <<<EOF
Copyright (c) {$this->copyrightYears->toString()} {$this->author->toString()}
Copyright (c) {$this->years->toString()} {$this->holder->toString()}
@see {$this->url->toString()}
EOF;
}

return <<<EOF
Copyright (c) {$this->copyrightYears->toString()} {$this->author->toString()}
Copyright (c) {$this->years->toString()} {$this->holder->toString()}
{$this->notice->toString()}
Expand Down
Expand Up @@ -11,18 +11,18 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License;
namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License\Copyright;

use Ergebnis\PhpCsFixer\Config\License\Author;
use Ergebnis\PhpCsFixer\Config\License\Copyright\Holder;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\License\Author
* @covers \Ergebnis\PhpCsFixer\Config\License\Copyright\Holder
*/
final class AuthorTest extends Framework\TestCase
final class HolderTest extends Framework\TestCase
{
use Helper;

Expand All @@ -36,7 +36,7 @@ public function testFromStringRejectsInvalidValue(string $value): void
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Value cannot be blank or empty.');

Author::fromString($value);
Holder::fromString($value);
}

public function provideInvalidValue(): \Generator
Expand All @@ -58,11 +58,11 @@ public function provideInvalidValue(): \Generator
*
* @param string $value
*/
public function testFromStringReturnsAuthor(string $value): void
public function testFromStringReturnsHolder(string $value): void
{
$author = Author::fromString($value);
$holder = Holder::fromString($value);

self::assertSame($value, $author->toString());
self::assertSame($value, $holder->toString());
}

public function provideValidValue(): \Generator
Expand All @@ -79,11 +79,11 @@ public function provideValidValue(): \Generator
*
* @param string $value
*/
public function testFromStringReturnsAuthorWithTrimmedValue(string $value): void
public function testFromStringReturnsHolderWithTrimmedValue(string $value): void
{
$author = Author::fromString($value);
$holder = Holder::fromString($value);

self::assertSame(\trim($value), $author->toString());
self::assertSame(\trim($value), $holder->toString());
}

public function provideUntrimmedValue(): \Generator
Expand Down
Expand Up @@ -11,16 +11,16 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License;
namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License\Copyright;

use Ergebnis\PhpCsFixer\Config\License\Year;
use Ergebnis\PhpCsFixer\Config\License\Copyright\Year;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\License\Year
* @covers \Ergebnis\PhpCsFixer\Config\License\Copyright\Year
*/
final class YearTest extends Framework\TestCase
{
Expand Down
92 changes: 92 additions & 0 deletions test/Unit/License/Copyright/YearsTest.php
@@ -0,0 +1,92 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2019 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License\Copyright;

use Ergebnis\PhpCsFixer\Config\License\Copyright\Year;
use Ergebnis\PhpCsFixer\Config\License\Copyright\Years;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\License\Copyright\Years
*
* @uses \Ergebnis\PhpCsFixer\Config\License\Copyright\Holder
* @uses \Ergebnis\PhpCsFixer\Config\License\Copyright\Year
* @uses \Ergebnis\PhpCsFixer\Config\License\Url
*/
final class YearsTest extends Framework\TestCase
{
use Helper;

public function testFromRangeRequiresStartYearToBeEqualOrLessThanEndYear(): void
{
$start = Year::fromString('2020');
$end = Year::fromString('2019');

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(\sprintf(
'Start year "%s" needs to be equal to or less than end year "%s".',
$start->toString(),
$end->toString()
));

Years::fromRange(
$start,
$end
);
}

public function testFromRangeReturnsYearsWhenStartYearEqualsEndYear(): void
{
$start = Year::fromString('2020');
$end = Year::fromString('2020');

$years = Years::fromRange(
$start,
$end
);

self::assertSame($start->toString(), $years->toString());
}

public function testFromRangeReturnsYearsWhenStartYearIsLessThanEndYear(): void
{
$start = Year::fromString('2019');
$end = Year::fromString('2020');

$years = Years::fromRange(
$start,
$end
);

$expected = \sprintf(
'%s-%s',
$start->toString(),
$end->toString()
);

self::assertSame($expected, $years->toString());
}

public function testFromYearReturnsYears(): void
{
$year = Year::fromString('2019');

$years = Years::fromYear($year);

self::assertSame($year->toString(), $years->toString());
}
}

0 comments on commit 1f5b17b

Please sign in to comment.