| Conditions | 10 | 
| Paths | 24 | 
| Total Lines | 26 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 44 | public function isValid($value, $context = [])  | 
            ||
| 45 |     { | 
            ||
| 46 | |||
| 47 | $this->valid = true;  | 
            ||
| 48 | |||
| 49 |         if (!isset($value->socid) && empty($value->name)) { | 
            ||
| 50 |             $this->addError('name', 'Le nom est requis pour créer une commande'); | 
            ||
| 51 | }  | 
            ||
| 52 |         if (!isset($value->socid) && empty($value->email) && empty($value->phone)) { | 
            ||
| 53 |             $this->addWarning('Soit l\'e-mail soit le téléphone n\'a pas été complété'); | 
            ||
| 54 | }  | 
            ||
| 55 |         if (empty($value->nbrPax) || (int)$value->nbrPax <= 0) { | 
            ||
| 56 |             $this->addError('nbrPax', 'Le nombre de passagers doit être plus grand que 0.'); | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 |         if ((int)$value->nbrPax > 0) { | 
            ||
| 60 | $costPerPax = $value->cost / (int)$value->nbrPax;  | 
            ||
| 61 |             if ($costPerPax < $this->getMinPrice()) { | 
            ||
| 62 |                 $this->addError('cost', | 
            ||
| 63 |                     sprintf('Le prix demandé par passagé est trop peu élevé. Un minimum de %s est demandé', | 
            ||
| 64 | $this->getMinPrice()));  | 
            ||
| 65 | }  | 
            ||
| 66 | }  | 
            ||
| 67 | |||
| 68 | return $this->valid;  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 83 | }  |