Skip to content

Commit

Permalink
required flag on item
Browse files Browse the repository at this point in the history
  • Loading branch information
panakour committed Aug 25, 2019
1 parent 1a6d3a4 commit 47b3b55
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Items/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ abstract class Item

protected $originalExtractedValue;

protected $required = true;

/**
* @var Cleaner[]
*/
Expand Down Expand Up @@ -184,7 +186,7 @@ protected function doRemove()
public function build()
{
$this->doExtract();
if (empty($this->extractedValue)) {
if (empty($this->extractedValue) && $this->isRequired()) {
throw new EmptyItemException("code:" . $this->code . " selector:" . $this->selector);
}
$this->doClone();
Expand All @@ -195,4 +197,20 @@ public function build()
}

abstract protected function doExtract();

/**
* @return bool
*/
public function isRequired(): bool
{
return $this->required;
}

/**
* @param bool $required
*/
public function setRequired(bool $required): void
{
$this->required = $required;
}
}

0 comments on commit 47b3b55

Please sign in to comment.