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);
        }
    }
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);
        }
    }
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 ) ; } }
Applies casts to currently set attributes.

This updates the values stored for the attributes with a cast type.

@param bool $scalarOnly
Applies casts to currently set attributes .