public static function toArray($object): array
    {
        $array = array();

        $class = get_class($object);

        $methods = get_class_methods($class);

        foreach ($methods as $method) {

            preg_match(' /^(get)(.*?)$/i', $method, $results);

            $pre = $results[1] ?? '';

            $k = $results[2] ?? '';

            $k = strtolower(substr($k, 0, 1)) . substr($k, 1);

            if ($pre == 'get') {

                $array[$k] = $object->$method();
            }
        }
        return array_filter($array);
    }
public static function toArray($object): array
    {
        $array = array();

        $class = get_class($object);

        $methods = get_class_methods($class);

        foreach ($methods as $method) {

            preg_match(' /^(get)(.*?)$/i', $method, $results);

            $pre = $results[1] ?? '';

            $k = $results[2] ?? '';

            $k = strtolower(substr($k, 0, 1)) . substr($k, 1);

            if ($pre == 'get') {

                $array[$k] = $object->$method();
            }
        }
        return array_filter($array);
    }
public static function toArray ( $ object ) : array { $ array = array ( ) ; $ class = get_class ( $ object ) ; $ methods = get_class_methods ( $ class ) ; foreach ( $ methods as $ method ) { preg_match ( ' /^(get)(.*?)$/i' , $ method , $ results ) ; $ pre = $ results [ 1 ] ?? '' ; $ k = $ results [ 2 ] ?? '' ; $ k = strtolower ( substr ( $ k , 0 , 1 ) ) . substr ( $ k , 1 ) ; if ( $ pre == 'get' ) { $ array [ $ k ] = $ object -> $ method ( ) ; } } return array_filter ( $ array ) ; }
Extract values from an object
converting the object to an associative array
@param  object $object
@return array
Extract values from an object converting the object to an associative array