コード例 #1
0
 /**
  * @param ElementInterface $element
  *
  * @throws ValidationError
  */
 public function validate(ElementInterface $element)
 {
     if ($element->isLeaf()) {
         if (strlen($element->getContent()) === 0) {
             throw new ValidationError(sprintf($this->message, 'content'));
         }
     } else {
         if (count($element->getChildren()) === 0) {
             throw new ValidationError(sprintf($this->message, 'children[]'));
         }
     }
 }