getMessageByCode($code), $code, $previous ); } private function getMessageByCode(int $code): string { switch ($code) { case self::TYPE_INCORRECT: return sprintf( "Password is incorrect for user <%s>!", $this->user->getEmail()->value ); case self::TYPE_SAME_AS_OLD: return sprintf( "New password is the same as old for user <%s>!", $this->user->getEmail()->value ); default: return "Password is invalid!"; } } }