Commit 00c0d057 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Amélioration du __toString d'un Result

parent a33810cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ class ConsoleController extends AbstractConsoleController
                }
            }
            
            $this->getConsole()->writeLine((string)$result);
            $this->getConsole()->writeLine($result->toString());
            $this->getConsole()->writeLine("Synchro terminée.", ColorInterface::NORMAL);

            $startDate = $result->getStartDate();
+1 −28
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ abstract class Result implements ResultInterface

        $str = '';
        foreach ($this->resultsByOperation as $operation => $result) {
            $str .= "# " . $operation . " : " . PHP_EOL;
            $str .= "# " . sprintf('%-12s', $operation . " : ");
            if (is_array($result)) {
                $str .= $result['count'] . " instructions exécutées.";
            } elseif ($result instanceof Exception){
@@ -146,33 +146,6 @@ abstract class Result implements ResultInterface
        return $str;
    }

    /**
     * @param bool $includeDetails
     * @return string
     */
    public function toStringOld($includeDetails = false)
    {
        if ($ex = $this->getFailure()) {
            return $ex->getMessage() . PHP_EOL . $ex->getTraceAsString();
        }

        if (count($this->resultsByOperation) === 0) {
            return "Aucune instruction exécutée.";
        }

        $str = '';
        foreach ($this->resultsByOperation as $operation => $results) {
            $str .= "# " . $operation . " : " . PHP_EOL;
            if ($includeDetails && isset($results['details'])) {
                $str .= $results['details'] . PHP_EOL;
            }
            $str .= $results['count'] . " instructions exécutées.";
            $str .= PHP_EOL;
        }

        return $str;
    }

    /**
     * @return string
     */