/** * {@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); }
/** * {@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); }
/** * {@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); }
/** * {@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); }
/** * 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; }