| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 62 | 
| Code Lines | 5 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | ||
| 24 | public function handle() | ||
| 25 |     { | ||
| 26 |         $isbn = $this->getParam('isbn') ?? ''; | ||
| 27 |         if (empty($isbn)) { | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | |||
| 31 | // ISBN-13 à partir de 2007 | ||
| 32 | $year = $this->findBookYear(); | ||
|  | |||
| 33 | //        if ($year !== null && $year < 2007 && 10 === strlen($this->stripIsbn($isbn))) { | ||
| 34 | // // juste mise en forme ISBN-10 pour 'isbn' | ||
| 35 | //            try { | ||
| 36 | // $isbnMachine = new IsbnFacade($isbn); | ||
| 37 | // // skip trigger_error() for deprecated method | ||
| 38 | // @$isbnMachine->validate(); | ||
| 39 | //                $isbn10pretty = $isbnMachine->format('ISBN-10'); | ||
| 40 | //                if ($isbn10pretty !== $isbn) { | ||
| 41 | //                    $this->setParam('isbn', $isbn10pretty); | ||
| 42 | //                    $this->addSummaryLog('ISBN10'); | ||
| 43 | // // $this->notCosmetic = true; | ||
| 44 | // } | ||
| 45 | //            } catch (Throwable $e) { | ||
| 46 | // // ISBN not validated | ||
| 47 | // $this->setParam( | ||
| 48 | // 'isbn invalide', | ||
| 49 | //                    sprintf('%s %s', $isbn, $e->getMessage() ?? '') | ||
| 50 | // ); | ||
| 51 | //                $this->addSummaryLog(sprintf('ISBN invalide: %s', $e->getMessage())); | ||
| 52 | // $this->optiStatus->setNotCosmetic(true); | ||
| 53 | // } | ||
| 54 | // | ||
| 55 | // return; | ||
| 56 | // } | ||
| 57 | |||
| 58 | //        try { | ||
| 59 | // $isbnMachine = new IsbnFacade($isbn); | ||
| 60 | // // skip trigger_error() for deprecated method | ||
| 61 | // @$isbnMachine->validate(); | ||
| 62 | //            $isbn13 = @$isbnMachine->format('ISBN-13'); | ||
| 63 | //        } catch (Throwable $e) { | ||
| 64 | // // ISBN not validated | ||
| 65 | // // TODO : bot ISBN invalide (queue, message PD...) | ||
| 66 | // $this->setParam( | ||
| 67 | // 'isbn invalide', | ||
| 68 | //                sprintf('%s %s', $isbn, $e->getMessage() ?? '') | ||
| 69 | // ); | ||
| 70 | //            $this->addSummaryLog(sprintf('ISBN invalide: %s', $e->getMessage())); | ||
| 71 | // $this->optiStatus->setNotCosmetic(true); | ||
| 72 | // | ||
| 73 | // // TODO log file ISBNinvalide | ||
| 74 | // return; | ||
| 75 | // } | ||
| 76 | |||
| 77 | // // Si $isbn13 et 'isbn2' correspond à ISBN-13 => suppression | ||
| 78 | //        if ($this->hasParamValue('isbn2') | ||
| 79 | //            && $this->stripIsbn($this->getParam('isbn2')) === $this->stripIsbn($isbn13) | ||
| 80 | //        ) { | ||
| 81 | //            $this->unsetParam('isbn2'); | ||
| 82 | // } | ||
| 83 | |||
| 84 | // ISBN-10 ? | ||
| 85 | $stripIsbn = $this->stripIsbn($isbn); | ||
| 86 | //        if (10 === mb_strlen($stripIsbn)) { | ||
| 141 | } |