public function setValue($value)
{
if ($this->isBoolean() && !is_bool($value)) {
throw new \Exception(sprintf('Boolean option expected for option %s, received %s value instead', $this->name, $value));
}
if (!$this->validate($value)) {
throw new \Exception(sprintf('Invalid value, %s, for option %s', $value, $this->name));
}
if ($this->isIncrement()) {
if (!is_int($value)) {
throw new \Exception(sprintf('Integer expected as value for %s, received %s instead', $this->name, $value));
}
if ($value > $this->max_value && $this->max_value > 0) {
$value = $this->max_value;
}
}
if ($this->isFile()) {
$file_path = $this->parseFilePath($value);
if (empty($file_path)) {
if ($this->file_require_exists) {
throw new \Exception(sprintf('Expected %s to be a valid file', $value, $this->name));
}
} else {
$value = $file_path;
}
}
$this->value = $this->map($value);
}