Skip to content

Commit

Permalink
Getter functions added to Table Tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Nov 12, 2024
1 parent 54b42c8 commit 63a490b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion debian/php-vitexsoftware-ease-html.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ esac

exit 0

#DEBHELPER#
#DEBHELPER#
41 changes: 28 additions & 13 deletions src/Ease/Html/TableTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,35 @@ class TableTag extends PairTag
* @param mixed $content inserted value
* @param array $properties table tag properties
*/
public function __construct($content = null, $properties = [])
public function __construct($content = null, array $properties = [])
{
parent::__construct('table', $properties);
$this->tHead = new Thead();
$this->tBody = new Tbody($content);
$this->tFoot = new Tfoot();
parent::__construct('table', $properties);
}

public function getHead(): Thead
{
return $this->tHead ?? $this->tHead = new Thead();
}

public function getBody(): Tbody
{
return $this->tBody ?? $this->tBody = new Tbody();
}

public function getFoot(): Tfoot
{
return $this->tFoot ?? $this->tFoot = new Tfoot();
}

/**
* @param array $headerColumns table header items
*/
public function setHeader(array $headerColumns): void
{
$this->tHead->emptyContents();
$this->getHead()->emptyContents();
$this->addRowHeaderColumns($headerColumns);
}

Expand All @@ -70,7 +85,7 @@ public function setHeader(array $headerColumns): void
*/
public function &addRowColumns($columns = null, $properties = [])
{
$tableRow = $this->tBody->addItem(new TrTag());
$tableRow = $this->getBody()->addItem(new TrTag());

if (\is_array($columns)) {
foreach ($columns as $column) {
Expand All @@ -97,7 +112,7 @@ public function &addRowColumns($columns = null, $properties = [])
*/
public function &addRowHeaderColumns($columns = null, $properties = [])
{
$tableRow = $this->tHead->addItem(new TrTag());
$tableRow = $this->getHead()->addItem(new TrTag());

if (\is_array($columns)) {
foreach ($columns as $column) {
Expand All @@ -124,7 +139,7 @@ public function &addRowHeaderColumns($columns = null, $properties = [])
*/
public function &addRowFooterColumns($columns = null, $properties = [])
{
$tableRow = $this->tFoot->addItem(new TrTag());
$tableRow = $this->getFoot()->addItem(new TrTag());

if (\is_array($columns)) {
foreach ($columns as $column) {
Expand All @@ -146,7 +161,7 @@ public function &addRowFooterColumns($columns = null, $properties = [])
*/
public function isEmpty(): bool
{
return $this->tBody->isEmpty();
return $this->getBody()->isEmpty();
}

/**
Expand All @@ -155,7 +170,7 @@ public function isEmpty(): bool
#[\Override]
public function emptyContents(): void
{
$this->tBody->emptyContents();
$this->getBody()->emptyContents();
}

/**
Expand All @@ -164,12 +179,12 @@ public function emptyContents(): void
#[\Override]
public function getContents()
{
return $this->tBody->getContents();
return $this->getBody()->getContents();
}

public function getFirstPart()
{
return $this->tBody->getFirstPart();
return $this->getBody()->getFirstPart();
}

/**
Expand All @@ -179,7 +194,7 @@ public function getFirstPart()
*/
public function getItemsCount(): int
{
return $this->tBody->getItemsCount();
return $this->getBody()->getItemsCount();
}

/**
Expand All @@ -204,13 +219,13 @@ public function populate($contents)
#[\Override]
public function finalize(): void
{
if ($this->tHead->isEmpty() === false) {
if ($this->getHead()->isEmpty() === false) {
$this->addItem($this->tHead);
}

$this->addItem($this->tBody);

if ($this->tFoot->isEmpty() === false) {
if ($this->getFoot()->isEmpty() === false) {
$this->addItem($this->tFoot);
}

Expand Down

0 comments on commit 63a490b

Please sign in to comment.