map(function ($hex) { return \hexdec($hex); }); // * Set Transparency as float $hexString = $intValues->push(\round($intValues->pop() / 100, 2))->implode(','); return "rgba($hexString)"; } /** * Prepare the given value for storage. * * @param Model $model * @param string $key * @param mixed $value * @param array $attributes * @return integer * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing * @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed */ public function set($model, $key, $value, $attributes) { // phpcs:enable $value = \rtrim(\ltrim(\str_replace(' ', '', \str_replace('rgba', '', \strval($value))), '('), ')'); $intValues = collect(\explode(',', $value))->map(function ($val) { return \floatval($val); }); // * Set Transparency as int $hexConcat = $intValues->push($intValues->pop() * 100)->map(function ($value) { return $this->zeropad(dechex(\intval($value)), 2); })->implode(''); return \intval(\hexdec($hexConcat)); } }