protected function applyCasts(bool $scalarOnly = false): void
    {
        // @codeCoverageIgnoreStart
        if ( ! $scalarOnly) {

            foreach (array_keys($this->casts()) as $key) {

                $this->applyCast($key);
            }

            return;
        }
        // @codeCoverageIgnoreEnd

        foreach ($this->casts() as $key => $type) {

            if ( ! in_array($type, static::SCALAR_CASTS)) {
                continue;
            }

            $this->applyCast($key);
        }
    }