Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function getErrorMessage() : string
 {
     $opts = \sndsgd\Arr::implode(", ", $this->getWrappedOptions(), _("or") . " ");
     if ($this->errorMessage) {
         return sprintf($this->errorMessage, $opts);
     }
     return sprintf(_("must be %s"), $opts);
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function getErrorMessage() : string
 {
     $template = _("value must be a child of %s");
     if (count($this->parentPaths) === 1) {
         return sprintf($template, $this->parentPaths[0]);
     }
     $parents = \sndsgd\Arr::implode(", ", $this->parentPaths, _("or") . " ");
     return sprintf($template, $parents);
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function getErrorMessage() : string
 {
     if (count($this->extensions) === 1) {
         $template = _("must be a file with a %s extension");
         $value = $this->extensions[0];
     } else {
         $template = _("must be a file with one of the following extensions: %s");
         $value = \sndsgd\Arr::implode(", ", $this->extensions, _("or") . " ");
     }
     return sprintf($template, $value);
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function getErrorMessage() : string
 {
     if ($this->errorMessage) {
         return $this->errorMessage;
     }
     $testTypes = array_values($this->getTestTypes());
     switch (count($testTypes)) {
         case 0:
             return _("must be a file");
         case 1:
             $desc = $testTypes[0];
             break;
         case 2:
             $desc = $testTypes[0] . " " . _("and") . " " . $testTypes[1];
             break;
         default:
             $desc = \sndsgd\Arr::implode(", ", $testTypes, _("and") . " ");
     }
     return sprintf(_("must be a %s file"), $desc);
 }
Beispiel #5
0
 /**
  * Verify a node type is valid
  *
  * @param string $nodeType The value to verify
  * @return string The verified node type
  * @throws \InvalidArgumentException If the node type is not valid
  */
 protected function validateNodeType(string $nodeType) : string
 {
     if (!in_array($nodeType, static::$validNodeTypes)) {
         throw new \InvalidArgumentException("invalid value node type '{$nodeType}'; expecting " . \sndsgd\Arr::implode(", ", static::$validNodeTypes, "or "));
     }
     return $nodeType;
 }