src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php
protected function getCastsReplace()
    {
        $attributes = $this->data['casts'] ?: [];

        if ( ! count($attributes)) return '';

        // align assignment signs by longest attribute
        $longestLength = 0;

        foreach ($attributes as $attribute => $type) {

            if (strlen($attribute) > $longestLength) {
                $longestLength = strlen($attribute);
            }
        }

        $replace = $this->tab() . "protected \$casts = [\n";

        foreach ($attributes as $attribute => $type) {

            $replace .= $this->tab(2)
                . "'" . str_pad($attribute . "'", $longestLength + 1)
                . " => '" . $type . "',\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getCastsReplace()
    {
        $attributes = $this->data['casts'] ?: [];

        if ( ! count($attributes)) return '';

        // align assignment signs by longest attribute
        $longestLength = 0;

        foreach ($attributes as $attribute => $type) {

            if (strlen($attribute) > $longestLength) {
                $longestLength = strlen($attribute);
            }
        }

        $replace = $this->tab() . "protected \$casts = [\n";

        foreach ($attributes as $attribute => $type) {

            $replace .= $this->tab(2)
                . "'" . str_pad($attribute . "'", $longestLength + 1)
                . " => '" . $type . "',\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getCastsReplace ( ) { $ attributes = $ this -> data [ 'casts' ] ? : [ ] ; if ( ! count ( $ attributes ) ) return '' ; // align assignment signs by longest attribute $ longestLength = 0 ; foreach ( $ attributes as $ attribute => $ type ) { if ( strlen ( $ attribute ) > $ longestLength ) { $ longestLength = strlen ( $ attribute ) ; } } $ replace = $ this -> tab ( ) . "protected \$casts = [\n" ; foreach ( $ attributes as $ attribute => $ type ) { $ replace .= $ this -> tab ( 2 ) . "'" . str_pad ( $ attribute . "'" , $ longestLength + 1 ) . " => '" . $ type . "',\n" ; } $ replace .= $ this -> tab ( ) . "];\n\n" ; return $ replace ; }
Returns the replacement for the casts placeholder

@return string
Returns the replacement for the casts placeholder