PHP – class – proper method naming
Imagine you have a class

class CRMViaProgramOrderCreator
{
 private $source; 
}

 

You need to check the correspondence of the value of it to certain exact value.

 

So you create a method and it looks now like

class CRMViaProgramOrderCreator
{
  private $source;
/**
*
* @return bool
*/
public function getSourceXlsIs()
{
return $this->source == Order::SOURCE_EXCEL;
}
}

 

Pay attention to the name of the method.

It’s named as getSourceXlsIs,  not getIsSourceXls and not getSourceXls.

Such naming is very convenient in later usage of class. You put first the noun and later its characteristics.

Like in French – noun first and then adjective (in the most of cases).



Leave a Reply

Your email address will not be published. Required fields are marked *