mirror of
https://github.com/YGGverse/gemtext-php.git
synced 2026-03-31 17:55:38 +00:00
implement class interfaces
This commit is contained in:
parent
b7b4a8c230
commit
2643878aae
8 changed files with 30 additions and 7 deletions
2
src/Entity/Code.php
Normal file → Executable file
2
src/Entity/Code.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Code
|
class Code implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
public const TAG = '```';
|
public const TAG = '```';
|
||||||
|
|
||||||
|
|
|
||||||
2
src/Entity/Header.php
Normal file → Executable file
2
src/Entity/Header.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Header
|
class Header implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
public const TAG = '#';
|
public const TAG = '#';
|
||||||
|
|
||||||
|
|
|
||||||
2
src/Entity/Link.php
Normal file → Executable file
2
src/Entity/Link.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Link
|
class Link implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
public const TAG = '=>';
|
public const TAG = '=>';
|
||||||
|
|
||||||
|
|
|
||||||
2
src/Entity/Listing.php
Normal file → Executable file
2
src/Entity/Listing.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Listing
|
class Listing implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
public const TAG = '*';
|
public const TAG = '*';
|
||||||
|
|
||||||
|
|
|
||||||
2
src/Entity/Quote.php
Normal file → Executable file
2
src/Entity/Quote.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Quote
|
class Quote implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
public const TAG = '>';
|
public const TAG = '>';
|
||||||
|
|
||||||
|
|
|
||||||
4
src/Entity/Text.php
Normal file → Executable file
4
src/Entity/Text.php
Normal file → Executable file
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Yggverse\Gemtext\Entity;
|
namespace Yggverse\Gemtext\Entity;
|
||||||
|
|
||||||
class Text
|
class Text implements \Yggverse\Gemtext\Interface\Entity
|
||||||
{
|
{
|
||||||
private string $_data;
|
private string $_data;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $data,
|
string $data = '',
|
||||||
bool $trim = false
|
bool $trim = false
|
||||||
) {
|
) {
|
||||||
$this->setData(
|
$this->setData(
|
||||||
|
|
|
||||||
10
src/Interface/Entity.php
Executable file
10
src/Interface/Entity.php
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Yggverse\Gemtext\Interface;
|
||||||
|
|
||||||
|
interface Entity
|
||||||
|
{
|
||||||
|
public function toString(): string;
|
||||||
|
}
|
||||||
13
src/Interface/Parser.php
Executable file
13
src/Interface/Parser.php
Executable file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Yggverse\Gemtext\Interface;
|
||||||
|
|
||||||
|
interface Parser
|
||||||
|
{
|
||||||
|
public static function match(
|
||||||
|
string $line,
|
||||||
|
array &$matches = []
|
||||||
|
): bool;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue