public function next() {


        // if this is a valid name
        if ($this->isValid()) {

            // find it on the index of colors
            $colorNames = Colors::getW3CIndex();

            // get the position of the name in the color index
            $pos = array_search($this->name,$colorNames);

            // if it was found on the array
            if ($pos !== false) {

                // if is the last item on the list
                if ($pos === (count($colorNames)-1)) {

                    // return the first item
                    return $colorNames[0];

                // it is not last
                } else {

                    // simply return the next item on the list
                    return $colorNames[$pos+1];
                }

            // name not found in list
            } else {

                // if it is not a W3C color, return null
                return null;

            }

        // invalid color
        } else {
            return null;
        }
        

        
    }
public function next() {


        // if this is a valid name
        if ($this->isValid()) {

            // find it on the index of colors
            $colorNames = Colors::getW3CIndex();

            // get the position of the name in the color index
            $pos = array_search($this->name,$colorNames);

            // if it was found on the array
            if ($pos !== false) {

                // if is the last item on the list
                if ($pos === (count($colorNames)-1)) {

                    // return the first item
                    return $colorNames[0];

                // it is not last
                } else {

                    // simply return the next item on the list
                    return $colorNames[$pos+1];
                }

            // name not found in list
            } else {

                // if it is not a W3C color, return null
                return null;

            }

        // invalid color
        } else {
            return null;
        }
        

        
    }
public function next ( ) { // if this is a valid name if ( $ this -> isValid ( ) ) { // find it on the index of colors $ colorNames = Colors :: getW3CIndex ( ) ; // get the position of the name in the color index $ pos = array_search ( $ this -> name , $ colorNames ) ; // if it was found on the array if ( $ pos !== false ) { // if is the last item on the list if ( $ pos === ( count ( $ colorNames ) - 1 ) ) { // return the first item return $ colorNames [ 0 ] ; // it is not last } else { // simply return the next item on the list return $ colorNames [ $ pos + 1 ] ; } // name not found in list } else { // if it is not a W3C color, return null return null ; } // invalid color } else { return null ; } }
Return the next name on the main Colors name index
@return string | null - return null if this color is not valid, otherwise, return the next name or
the first name, if this is the last name
Return the next name on the main Colors name index