Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Rename namespace and class #25

Merged
merged 1 commit into from Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .php_cs
Expand Up @@ -13,16 +13,16 @@ declare(strict_types=1);

use Ergebnis\PhpCsFixer\Config;

$header = Config\Header\Header::create(
Config\Header\CopyrightYears::fromYear(Config\Header\Year::fromString('2019')),
Config\Header\Author::fromString('Andreas Möller'),
Config\Header\License::fromString(
$header = Config\License\Header::create(
Config\License\CopyrightYears::fromYear(Config\License\Year::fromString('2019')),
Config\License\Author::fromString('Andreas Möller'),
Config\License\Notice::fromString(
<<<'EOF'
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF
),
Config\Header\Url::fromString('https://github.com/ergebnis/php-cs-fixer-config')
Config\License\Url::fromString('https://github.com/ergebnis/php-cs-fixer-config')
);

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header->toString()));
Expand Down
2 changes: 1 addition & 1 deletion src/Header/Author.php → src/License/Author.php
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

/**
* @internal
Expand Down
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

/**
* @internal
Expand Down
16 changes: 8 additions & 8 deletions src/Header/Header.php → src/License/Header.php
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

/**
* @internal
Expand All @@ -22,31 +22,31 @@ final class Header

private $author;

private $license;
private $notice;

private $url;

private function __construct(CopyrightYears $copyrightYear, Author $author, License $license, Url $url)
private function __construct(CopyrightYears $copyrightYear, Author $author, Notice $notice, Url $url)
{
$this->copyrightYear = $copyrightYear;
$this->author = $author;
$this->license = $license;
$this->notice = $notice;
$this->url = $url;
}

public static function create(CopyrightYears $copyrightYear, Author $author, License $license, Url $url): self
public static function create(CopyrightYears $copyrightYear, Author $author, Notice $notice, Url $url): self
{
return new self(
$copyrightYear,
$author,
$license,
$notice,
$url
);
}

public function toString(): string
{
if ($this->license->isEmpty()) {
if ($this->notice->isEmpty()) {
return <<<EOF
Copyright (c) {$this->copyrightYear->toString()} {$this->author->toString()}

Expand All @@ -57,7 +57,7 @@ public function toString(): string
return <<<EOF
Copyright (c) {$this->copyrightYear->toString()} {$this->author->toString()}

{$this->license->toString()}
{$this->notice->toString()}

@see {$this->url->toString()}
EOF;
Expand Down
4 changes: 2 additions & 2 deletions src/Header/License.php → src/License/Notice.php
Expand Up @@ -11,12 +11,12 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

/**
* @internal
*/
final class License
final class Notice
{
private $value;

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

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

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

namespace Ergebnis\PhpCsFixer\Config\Header;
namespace Ergebnis\PhpCsFixer\Config\License;

/**
* @internal
Expand Down
Expand Up @@ -11,16 +11,16 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

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

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

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\Author
* @covers \Ergebnis\PhpCsFixer\Config\License\Author
*/
final class AuthorTest extends Framework\TestCase
{
Expand Down
Expand Up @@ -11,21 +11,21 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

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

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

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\CopyrightYears
* @covers \Ergebnis\PhpCsFixer\Config\License\CopyrightYears
*
* @uses \Ergebnis\PhpCsFixer\Config\Header\Author
* @uses \Ergebnis\PhpCsFixer\Config\Header\Url
* @uses \Ergebnis\PhpCsFixer\Config\Header\Year
* @uses \Ergebnis\PhpCsFixer\Config\License\Author
* @uses \Ergebnis\PhpCsFixer\Config\License\Url
* @uses \Ergebnis\PhpCsFixer\Config\License\Year
*/
final class CopyrightYearsTest extends Framework\TestCase
{
Expand Down
Expand Up @@ -11,27 +11,27 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\Header;

use Ergebnis\PhpCsFixer\Config\Header\Author;
use Ergebnis\PhpCsFixer\Config\Header\CopyrightYears;
use Ergebnis\PhpCsFixer\Config\Header\Header;
use Ergebnis\PhpCsFixer\Config\Header\License;
use Ergebnis\PhpCsFixer\Config\Header\Url;
use Ergebnis\PhpCsFixer\Config\Header\Year;
namespace Ergebnis\PhpCsFixer\Config\Test\Unit\License;

use Ergebnis\PhpCsFixer\Config\License\Author;
use Ergebnis\PhpCsFixer\Config\License\CopyrightYears;
use Ergebnis\PhpCsFixer\Config\License\Header;
use Ergebnis\PhpCsFixer\Config\License\Notice;
use Ergebnis\PhpCsFixer\Config\License\Url;
use Ergebnis\PhpCsFixer\Config\License\Year;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\Header
* @covers \Ergebnis\PhpCsFixer\Config\License\Header
*
* @uses \Ergebnis\PhpCsFixer\Config\Header\Author
* @uses \Ergebnis\PhpCsFixer\Config\Header\CopyrightYears
* @uses \Ergebnis\PhpCsFixer\Config\Header\License
* @uses \Ergebnis\PhpCsFixer\Config\Header\Url
* @uses \Ergebnis\PhpCsFixer\Config\Header\Year
* @uses \Ergebnis\PhpCsFixer\Config\License\Author
* @uses \Ergebnis\PhpCsFixer\Config\License\CopyrightYears
* @uses \Ergebnis\PhpCsFixer\Config\License\Notice
* @uses \Ergebnis\PhpCsFixer\Config\License\Url
* @uses \Ergebnis\PhpCsFixer\Config\License\Year
*/
final class HeaderTest extends Framework\TestCase
{
Expand All @@ -53,7 +53,7 @@ public function testCreateReturnsHeaderWhenLicenseIsEmpty(): void
$header = Header::create(
$copyrightYears,
$author,
License::fromString(''),
Notice::fromString(''),
$url
);

Expand All @@ -77,7 +77,7 @@ public function testCreateReturnsHeaderWhenLicenseIsNotEmpty(): void

$author = Author::fromString($faker->name);

$license = License::fromString(
$notice = Notice::fromString(
<<<'EOF'
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
Expand All @@ -89,14 +89,14 @@ public function testCreateReturnsHeaderWhenLicenseIsNotEmpty(): void
$header = Header::create(
$copyrightYears,
$author,
$license,
$notice,
$url
);

$expected = <<<EOF
Copyright (c) {$copyrightYears->toString()} {$author->toString()}

{$license->toString()}
{$notice->toString()}

@see {$url->toString()}
EOF;
Expand Down
Expand Up @@ -11,18 +11,18 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

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

use Ergebnis\PhpCsFixer\Config\Header\License;
use Ergebnis\PhpCsFixer\Config\License\Notice;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\License
* @covers \Ergebnis\PhpCsFixer\Config\License\Notice
*/
final class LicenseTest extends Framework\TestCase
final class NoticeTest extends Framework\TestCase
{
use Helper;

Expand All @@ -31,11 +31,11 @@ final class LicenseTest extends Framework\TestCase
*
* @param string $value
*/
public function testFromStringReturnsLicense(string $value): void
public function testFromStringReturnsNotice(string $value): void
{
$license = License::fromString($value);
$notice = Notice::fromString($value);

self::assertSame($value, $license->toString());
self::assertSame($value, $notice->toString());
}

public function provideValidValue(): \Generator
Expand All @@ -52,11 +52,11 @@ public function provideValidValue(): \Generator
*
* @param string $value
*/
public function testFromStringReturnsLicenseWithTrimmedValue(string $value): void
public function testFromStringReturnsNoticeWithTrimmedValue(string $value): void
{
$license = License::fromString($value);
$notice = Notice::fromString($value);

self::assertSame(\trim($value), $license->toString());
self::assertSame(\trim($value), $notice->toString());
}

public function provideUntrimmedValue(): \Generator
Expand All @@ -73,9 +73,9 @@ public function provideUntrimmedValue(): \Generator

public function testIsEmptyReturnsFalseWhenTrimmedValueIsNotEmpty(): void
{
$license = License::fromString(self::faker()->realText());
$notice = Notice::fromString(self::faker()->realText());

self::assertFalse($license->isEmpty());
self::assertFalse($notice->isEmpty());
}

/**
Expand All @@ -85,9 +85,9 @@ public function testIsEmptyReturnsFalseWhenTrimmedValueIsNotEmpty(): void
*/
public function testIsEmptyReturnsTrueWhenTrimmedValueIsEmpty(string $value): void
{
$license = License::fromString($value);
$notice = Notice::fromString($value);

self::assertTrue($license->isEmpty());
self::assertTrue($notice->isEmpty());
}

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

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

use Ergebnis\PhpCsFixer\Config\Header\Url;
use Ergebnis\PhpCsFixer\Config\License\Url;
use Ergebnis\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\Url
* @covers \Ergebnis\PhpCsFixer\Config\License\Url
*/
final class UrlTest extends Framework\TestCase
{
Expand Down
Expand Up @@ -11,16 +11,16 @@
* @see https://github.com/ergebnis/php-cs-fixer-config
*/

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

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

/**
* @internal
*
* @covers \Ergebnis\PhpCsFixer\Config\Header\Year
* @covers \Ergebnis\PhpCsFixer\Config\License\Year
*/
final class YearTest extends Framework\TestCase
{
Expand Down