Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
97
vendor/doctrine/rst-parser/lib/Nodes/Table/TableColumn.php
vendored
Normal file
97
vendor/doctrine/rst-parser/lib/Nodes/Table/TableColumn.php
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Nodes\Table;
|
||||
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use LogicException;
|
||||
|
||||
use function mb_convert_encoding;
|
||||
use function strlen;
|
||||
use function trim;
|
||||
|
||||
final class TableColumn
|
||||
{
|
||||
/** @var string */
|
||||
private $content;
|
||||
|
||||
/** @var int */
|
||||
private $colSpan;
|
||||
|
||||
/** @var int */
|
||||
private $rowSpan = 1;
|
||||
|
||||
/** @var Node|null */
|
||||
private $node;
|
||||
|
||||
public function __construct(string $content, int $colSpan)
|
||||
{
|
||||
$this->content = mb_convert_encoding(trim($content), 'UTF-8', 'ISO-8859-1');
|
||||
$this->colSpan = $colSpan;
|
||||
}
|
||||
|
||||
public function getContent(): string
|
||||
{
|
||||
// "\" is a special way to make a column "empty", but
|
||||
// still indicate that you *want* that column
|
||||
if ($this->content === '\\') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function getColSpan(): int
|
||||
{
|
||||
return $this->colSpan;
|
||||
}
|
||||
|
||||
public function getRowSpan(): int
|
||||
{
|
||||
return $this->rowSpan;
|
||||
}
|
||||
|
||||
public function addContent(string $content): void
|
||||
{
|
||||
$this->content = trim($this->content . $content);
|
||||
}
|
||||
|
||||
public function incrementRowSpan(): void
|
||||
{
|
||||
$this->rowSpan++;
|
||||
}
|
||||
|
||||
public function getNode(): Node
|
||||
{
|
||||
if ($this->node === null) {
|
||||
throw new LogicException('The node is not yet set.');
|
||||
}
|
||||
|
||||
return $this->node;
|
||||
}
|
||||
|
||||
public function setNode(Node $node): void
|
||||
{
|
||||
$this->node = $node;
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$rendered = $this->getNode()->render();
|
||||
|
||||
if ($rendered === '' && $this->content !== '\\') {
|
||||
$rendered = ' ';
|
||||
}
|
||||
|
||||
return $rendered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a column is empty, and could be skipped entirely.
|
||||
*/
|
||||
public function isCompletelyEmpty(): bool
|
||||
{
|
||||
return strlen($this->content) === 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue