mirror of
https://github.com/YGGverse/gemtext-php.git
synced 2026-03-31 17:55:38 +00:00
cleanup namespace
This commit is contained in:
parent
207f785d7f
commit
765acc4754
3 changed files with 0 additions and 212 deletions
23
src/Code.php
23
src/Code.php
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Yggverse\Gemtext;
|
|
||||||
|
|
||||||
class Code
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Helper method
|
|
||||||
*
|
|
||||||
* Detect line given is escaped by previous iteration
|
|
||||||
*/
|
|
||||||
public static function escaped(string $line, bool &$status): bool
|
|
||||||
{
|
|
||||||
if (preg_match('/^```/m', $line))
|
|
||||||
{
|
|
||||||
$status = !($status); // toggle
|
|
||||||
}
|
|
||||||
|
|
||||||
return $status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
67
src/Line.php
67
src/Line.php
|
|
@ -1,67 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Yggverse\Gemtext;
|
|
||||||
|
|
||||||
class Line
|
|
||||||
{
|
|
||||||
private string $_data;
|
|
||||||
|
|
||||||
private bool $_escaped;
|
|
||||||
private ?int $_number;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
string $data = '',
|
|
||||||
bool $escaped = false,
|
|
||||||
?int $number = null
|
|
||||||
) {
|
|
||||||
$this->setData(
|
|
||||||
$data
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->setEscaped(
|
|
||||||
$escaped
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->setNumber(
|
|
||||||
$number
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getData(): string
|
|
||||||
{
|
|
||||||
return $this->_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setData(
|
|
||||||
string $data
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
$this->_data = $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEscaped(): bool
|
|
||||||
{
|
|
||||||
return $this->_escaped;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEscaped(
|
|
||||||
bool $escaped
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
$this->_escaped = $escaped;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNumber(): ?int
|
|
||||||
{
|
|
||||||
return $this->_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNumber(
|
|
||||||
?int $number
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
$this->_number = $number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
122
src/Link.php
122
src/Link.php
|
|
@ -1,122 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Yggverse\Gemtext;
|
|
||||||
|
|
||||||
class Link
|
|
||||||
{
|
|
||||||
private string $_address;
|
|
||||||
|
|
||||||
private ?string $_alt;
|
|
||||||
private ?string $_date;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
string $address,
|
|
||||||
?string $alt = null,
|
|
||||||
?string $date = null
|
|
||||||
) {
|
|
||||||
$this->setAddress(
|
|
||||||
$address
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->setAlt(
|
|
||||||
$alt
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->setDate(
|
|
||||||
$date
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAddress(
|
|
||||||
string $address
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
$address = trim(
|
|
||||||
$address
|
|
||||||
);
|
|
||||||
|
|
||||||
if (empty($address))
|
|
||||||
{
|
|
||||||
throw new \Exception(
|
|
||||||
_('Address required')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_address = $address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddress(): string
|
|
||||||
{
|
|
||||||
return $this->_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAlt(
|
|
||||||
?string $alt
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
if ($alt)
|
|
||||||
{
|
|
||||||
$alt = trim(
|
|
||||||
$alt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_alt = $alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAlt(): ?string
|
|
||||||
{
|
|
||||||
return $this->_alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDate(
|
|
||||||
?string $date
|
|
||||||
): void
|
|
||||||
{
|
|
||||||
if ($date)
|
|
||||||
{
|
|
||||||
$date = trim(
|
|
||||||
$date
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/'))
|
|
||||||
{
|
|
||||||
throw new \Exception(
|
|
||||||
_('Date does not match format YYYY-MM-DD')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_date = $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): ?string
|
|
||||||
{
|
|
||||||
return $this->_date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toString(): string
|
|
||||||
{
|
|
||||||
$parts = [
|
|
||||||
'=>',
|
|
||||||
$this->getAddress()
|
|
||||||
];
|
|
||||||
|
|
||||||
if ($date = $this->getDate())
|
|
||||||
{
|
|
||||||
$parts[] = $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($alt = $this->getAlt())
|
|
||||||
{
|
|
||||||
$parts[] = $alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(
|
|
||||||
' ',
|
|
||||||
$parts
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue