<?php
 class Usuario
    {
         private $nome;
         private $profissao;
    
         public function setNome($nome)
         {
             $this->nome = $nome;
             return $this;
         }

         public function setProfissao($profissao)
         {
             $this->profissao = $profissao;
             return $this;
         }
    
         public function getNome($nome)
         {
             return $this->nome;
         }
    
         public function getProfissao($profissao)
         {
             return $this->profissao;
         }
    
         public function getValueByAttributeName($name)
         {
            if (property_exists($this, $name)) {
                return $this->$name;
            }
         }
         
        public function getValueByMethodName($name)
        {
            $name = $name.'()';

            if (method_exists($this, $name)) {
               return $this->$name;
            }
        }
        
        public function getAllAttributes()
        {
            $array = array();

            foreach ($this as $key => $value) {
                if (property_exists($this, $key)) {
                     $array[] = array($key => $value);
                }
             } 
             return $array;

        }
    }
    
    $usuario = new Usuario;
    
    $usuario->setNome('Nome Qualquer');
    $usuario->setProfissao('Profissão Qualquer');
    $data = $usuario->getAllAttributes();
    
    echo 'Exemplo de listar tudo: <pre>';
    print_r($data);
    echo '</pre><br>Exemplo por método:<br>';
    echo '--->'.$usuario->getValueByMethodName('getnome');
    echo '<br>';
    echo '--->'.$usuario->getValueByMethodName('getprofissao');
    echo '<br>Exemplo por atributo:<br>';
    echo '--->'.$usuario->getValueByAttributeName('nome');
    echo '<br>';
    echo '--->'.$usuario->getValueByAttributeName('profissao');