0
How to reuse $dados
, $key
and $postFields
in all methods without having to repeat this data every time within each method? Yes, these variables will always have the same values.
class AllImoveis
{
/**
* Chaves de Autenticação
* @var string
*/
public function listar_imoveis()
{
$dados = array(fields =>array('tipo', 'cidade', 'bairro', 'codigo'));
$key = '82CDA6l0BBepOykevP0472xl9ZoKuIlH';
$postFields = json_encode($dados);
...
...
}
public function listar_imovel()
{
$dados = array(fields =>array('tipo', 'cidade', 'bairro', 'codigo'));
$key = '82CDA6l0BBepOykevP0472xl9ZoKuIlH';
$postFields = json_encode($dados);
...
...
}
}
It depends on what you want. Without a context it’s hard to say. Maybe you should repeat it. Maybe I should create a method that returns them or makes more granular manipulations, maybe I should turn them into class fields, maybe I should create an auxiliary class, maybe I should not do any of this and look for a solution that you dominate.
– Maniero