-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
775ef54
commit 86bcefa
Showing
13 changed files
with
241 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
library/PostObject/Decorators/PostObjectArchiveDateFormat.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
namespace Municipio\PostObject\Decorators; | ||
|
||
use Municipio\PostObject\Icon\IconInterface; | ||
use Municipio\PostObject\PostObjectInterface; | ||
use Municipio\PostObject\Date\ArchiveDateSettingResolverInterface; | ||
|
||
/** | ||
* PostObjectWithSeoRedirect class. | ||
* | ||
* Applies the SEO redirect to the post object permalink if a redirect is set. | ||
*/ | ||
class PostObjectArchiveDateFormat implements PostObjectInterface | ||
{ | ||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct( | ||
private PostObjectInterface $postObject, | ||
private ArchiveDateSettingResolverInterface $dateSettingResolver | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getId(): int | ||
{ | ||
return $this->postObject->getId(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getTitle(): string | ||
{ | ||
return $this->postObject->getTitle(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPermalink(): string | ||
{ | ||
return $this->postObject->getPermalink(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getCommentCount(): int | ||
{ | ||
return $this->postObject->getCommentCount(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getPostType(): string | ||
{ | ||
return $this->postObject->getPostType(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getBlogId(): int | ||
{ | ||
return $this->postObject->getBlogId(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getIcon(): ?IconInterface | ||
{ | ||
return $this->postObject->getIcon(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPublishedTime(bool $gmt = false): int | ||
{ | ||
return $this->postObject->getPublishedTime($gmt); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getModifiedTime(bool $gmt = false): int | ||
{ | ||
return $this->postObject->getModifiedTime($gmt); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getArchiveDateTimestamp(): int | ||
{ | ||
return $this->postObject->getArchiveDateTimestamp(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getArchiveDateFormat(): string | ||
{ | ||
return $this->dateSettingResolver->resolve(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
library/PostObject/Decorators/PostObjectArchiveDateFormat.test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Municipio\PostObject\Decorators; | ||
|
||
use Municipio\PostObject\Date\ArchiveDateSettingResolverInterface; | ||
use Municipio\PostObject\PostObject; | ||
use PHPUnit\Framework\TestCase; | ||
use WpService\Implementations\FakeWpService; | ||
|
||
class PostObjectArchiveDateFormatTest extends TestCase | ||
{ | ||
/** | ||
* @testdox class can be instantiated | ||
*/ | ||
public function testClassCanBeInstantiated() | ||
{ | ||
$resolver = $this->createMock(ArchiveDateSettingResolverInterface::class); | ||
$decorator = new PostObjectArchiveDateFormat(new PostObject(new FakeWpService()), $resolver); | ||
$this->assertInstanceOf(PostObjectArchiveDateFormat::class, $decorator); | ||
} | ||
|
||
/** | ||
* @testdox getDateTimestamp returns unix timestamp | ||
*/ | ||
public function testReturnsFormat() | ||
{ | ||
$resolver = $this->createMock(ArchiveDateSettingResolverInterface::class); | ||
$resolver->method('resolve')->willReturn('H:i'); | ||
|
||
$decorator = new PostObjectArchiveDateFormat(new PostObject(new FakeWpService()), $resolver); | ||
|
||
$this->assertEquals('H:i', $decorator->getArchiveDateFormat()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters