How to split the addressing of a class in PHP?

How best to divide this Aluno?

<?php
    class Aluno{
        private $nome;
        private $sobrenome;
        private $email;
        private $telefone;
        private $cep;
        private $rua;
        private $endereco;
        private $numero;
        private $logradouro;
        private $cidade;
        private $estado;
        private $usuario;
        private $senha;

        public function getNome(){
            return $this->nome;
        }
        public function setNome($nome){
            $this->nome = $nome;
        }

        public function getSobrenome(){
            return $this->sobrenome;
        }
        public function setSobrenome($sobrenome){
            $this->sobrenome = $sobrenome;
        }

        public function getEmail(){
            return $this->email;
        }
        public function setEmail($email){
            $this->email = $email;
        }


        public function getTelefone(){
            return $this->telefone;
        }
        public function setTelefone($telefone){
            $this->telefone = $telefone;
        }

        public function getCep(){
            return $this->cep;
        }
        public function setCep($cep){
            $this->cep = $cep;
        }

        public function getRua(){
            return $this->rua;
        }
        public function setRua($rua){
            $this->rua = $rua;
        }

        public function getEndereco(){
            return $this->endereco;
        }

        public function setEndereco($endereco){
            $this->endereco = $endereco;
        }

        public function getNumero(){
            return $this->numero;
        }
        public function setNumero($numero){
            $this->numero = $numero;
        }

        public function getLogradouro(){
            return $this->logradouro;
        }
        public function setLogradouro($lougradouro){
            $this->lougradouro = $logradouro;
        }


        public function getCidade(){
            return $this->cidade;
        }
        public function setCidade($cidade){
            $this->cidade = $cidade;
        }


        public function getEstado(){
            return $this->estado;
        }
        public function setEstado($estado){
            $this->estado = $estado;
        }

        public function getUsuario(){
            return $this->usuario;
        }

        public function setUsuario($usuario){
            $this->usuario = $usuario;
        }

        public function getSenha(){
            return $this->senha;
        }

        public function setSenha($senha){
            $this->senha = $senha;
        }



    }
?>

Would it be relevant to separate some information into another class as a database table? Type:

Class Telefone{
       private $ddd;
       private $numero;

      public function getDDD(){
        return $this->ddd;
      }
      public function setDDD($ddd){
        $this->ddd = $ddd;
      }
      public function getTelefone(){
        return $this->telefone;
      }
      public function setTelefone($telefone){
        $this->telefone = $telefone;
      }

Should I apply these classes and methods in the State (Class Estado get and set State), City (Class Cidade get and set City), address (Class Endereço containing number, zip code, complement, letterhead getters and setters etc).

This would also apply with Usuário and password create a class just for the two of you?

Example:

Class Estado{
       private $estado;

          public function getEstado(){
            return $this->estado;
          }
          public function setEstado($estado){
            $this->estado = $estado;
          }
}

Class Cidade{
       private $cidade

       public function getCidade(){
         return $this->cidade;
       }
       public function setCidade($cidade){
         $this->cidade = $cidade;
} 

Etc.

Note: when I model something like this, do you have any specific technique to separate correctly or will it depend on the programmer?

Author: Maniero, 2018-12-12

1 answers

Have already commented but I want to reinforce. You are programming as if you were in Java. In PHP usually does not need any of this. PHP is a language of script , it was created to make simple code and people started creating complex code, and say in passing, unnecessary. In general they do not know why they are doing it, they only do it because they have seen someone doing it somewhere, without understanding the reality and context of who did it. Probably this person did for the same reason you did, so just because you saw someone else doing it. It is a monkey Simon game that has nothing to do with engineering, which is our professional area.

Another problem with the question is wanting to know the best way to random people on the internet who do not know your problem. Or even worse, your problem may be artificial. People think that" solving " artificial problems teach developing software, but does not teach, at most teaches using a mechanism of the language, which is not the case of the question, she wants to know about data structure organization, which is only useful when you know 100% of the requirements and correctly. We don't know.

In addition, it spends as everyone is used to do, I would erase everything and start in a totally different, and simple way.

Only You know if it would be relevant to separate into parts. Can you justify that? Will there be any gain? Does it Serve any purpose? Don't you have a better way to do this? For what you have demonstrated does not need, but it may just be that you have demonstrated wrong to us, if you have done so any attempt at help will be wrong.

Modeling a data structure essentially depends on current requirements and possibility of future requirements. Modeling is experience. It is to take real, detailed cases and see if it works or not over time and learn from the mistakes, or even use the experience of other people to show where the mistakes are, as long as you have all necessary information. Modeling has to do with logical thinking befitting. It's understanding things that are not even computing.

The responses to the comments shows that you are stuck to a vision of getting things done. That's why I hate the way people put things on the internet, they ruin people's heads forever. The person can no longer see another way of making, everything turns into a meaningless cake recipe.

There are controversies about what classes are, but from general form they are the opposite of database tables, even though they look the same. I even wanted them to be used in a similar way, but that's not how people use it, but the subject is too broad to discuss here. Anyway this case looks like it's separating the individual data into separate tables, this seems very wrong, but it might just be because there are no clear requirements in the question.

 2
Author: Maniero, 2020-08-20 16:08:11