Questions about the design of the code ...
There is such a method:
/** * Activate module from ZIP archive * @param $archiveFilePath * @return bool */ public function activate($archiveFilePath) { if( file_exists($archiveFilePath) ) { $moduleDirectory = $this->extractArchive($archiveFilePath); if( $moduleDirectory ) { $moduleConfig = $this->getConfig($moduleDirectory); if( $moduleConfig ) { } else { \Yii::$app->session->setFlash(self::ERRORS_KEY, self::ERROR_INSTALL_CONFIG_NOT_EXIST); return false; } } else { \Yii::$app->session->setFlash(self::ERRORS_KEY, self::ERROR_ARCHIVE_EXTRACT); return false; } } else { \Yii::$app->session->setFlash(self::ERRORS_KEY, self::ERROR_ARCHIVE_NOT_EXIST); return false; } } We see a set of if . I constantly need to check the values that other class methods return and display errors if something is wrong.
Question 1 . The code turns out terrible (I just started it, there should be many such checks). How to do the right thing in such cases?
Question 2 . For example, I have an if( $moduleDirectory ) . The $moduleDirectory can be string or false . Is it worth writing? Or is it better to do this: if( $moduleDirectory !== false ) ?