public function createNames()
    {
        // names required for the PostType
        $required = [
            'name',
            'singular',
            'plural',
            'slug',
        ];

        foreach ($required as $key) {
            // if the name is set, assign it
            if (isset($this->names[$key])) {
                $this->$key = $this->names[$key];
                continue;
            }

            // if the key is not set and is singular or plural
            if (in_array($key, ['singular', 'plural'])) {
                // create a human friendly name
                $name = ucwords(strtolower(str_replace(['-', '_'], ' ', $this->names['name'])));
            }

            if ($key === 'slug') {
                // create a slug friendly name
                $name = strtolower(str_replace([' ', '_'], '-', $this->names['name']));
            }

            // if is plural or slug, append an 's'
            if (in_array($key, ['plural', 'slug'])) {
                $name .= 's';
            }

            // asign the name to the PostType property
            $this->$key = $name;
        }
    }
public function createNames()
    {
        // names required for the PostType
        $required = [
            'name',
            'singular',
            'plural',
            'slug',
        ];

        foreach ($required as $key) {
            // if the name is set, assign it
            if (isset($this->names[$key])) {
                $this->$key = $this->names[$key];
                continue;
            }

            // if the key is not set and is singular or plural
            if (in_array($key, ['singular', 'plural'])) {
                // create a human friendly name
                $name = ucwords(strtolower(str_replace(['-', '_'], ' ', $this->names['name'])));
            }

            if ($key === 'slug') {
                // create a slug friendly name
                $name = strtolower(str_replace([' ', '_'], '-', $this->names['name']));
            }

            // if is plural or slug, append an 's'
            if (in_array($key, ['plural', 'slug'])) {
                $name .= 's';
            }

            // asign the name to the PostType property
            $this->$key = $name;
        }
    }
public function createNames ( ) { // names required for the PostType $ required = [ 'name' , 'singular' , 'plural' , 'slug' , ] ; foreach ( $ required as $ key ) { // if the name is set, assign it if ( isset ( $ this -> names [ $ key ] ) ) { $ this -> $ key = $ this -> names [ $ key ] ; continue ; } // if the key is not set and is singular or plural if ( in_array ( $ key , [ 'singular' , 'plural' ] ) ) { // create a human friendly name $ name = ucwords ( strtolower ( str_replace ( [ '-' , '_' ] , ' ' , $ this -> names [ 'name' ] ) ) ) ; } if ( $ key === 'slug' ) { // create a slug friendly name $ name = strtolower ( str_replace ( [ ' ' , '_' ] , '-' , $ this -> names [ 'name' ] ) ) ; } // if is plural or slug, append an 's' if ( in_array ( $ key , [ 'plural' , 'slug' ] ) ) { $ name .= 's' ; } // asign the name to the PostType property $ this -> $ key = $ name ; } }
Create the required names for the PostType
@return void
Create the required names for the PostType