src/Sismo/Storage/PdoStorage.php
public function initCommit(Project $project, $sha, $author, \DateTime $date, $message)
    {
        $stmt = $this->db->prepare('SELECT COUNT(*) FROM `commit` WHERE slug = :slug');
        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to verify existence of commit "%s" from project "%s".', $sha, $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        if ($stmt->fetchColumn(0)) {
            $stmt = $this->db->prepare('UPDATE `commit` SET slug = :slug, sha = :sha, author = :author, date = :date, message = :message, status = :status, output = :output, build_date = :build_date WHERE slug = :slug');
        } else {
            $stmt = $this->db->prepare('INSERT INTO `commit` (slug, sha, author, date, message, status, output, build_date) VALUES (:slug, :sha, :author, :date, :message, :status, :output, :build_date)');
        }

        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
        $stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
        $stmt->bindValue(':author', $author, \PDO::PARAM_STR);
        $stmt->bindValue(':date', $date->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
        $stmt->bindValue(':message', $message, \PDO::PARAM_STR);
        $stmt->bindValue(':status', 'building', \PDO::PARAM_STR);
        $stmt->bindValue(':output', '', \PDO::PARAM_STR);
        $stmt->bindValue(':build_date', '', \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to save commit "%s" from project "%s".', $sha, $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        $commit = new Commit($project, $sha);
        $commit->setAuthor($author);
        $commit->setMessage($message);
        $commit->setDate($date);

        return $commit;
    }
public function initCommit(Project $project, $sha, $author, \DateTime $date, $message)
    {
        $stmt = $this->db->prepare('SELECT COUNT(*) FROM `commit` WHERE slug = :slug');
        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to verify existence of commit "%s" from project "%s".', $sha, $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        if ($stmt->fetchColumn(0)) {
            $stmt = $this->db->prepare('UPDATE `commit` SET slug = :slug, sha = :sha, author = :author, date = :date, message = :message, status = :status, output = :output, build_date = :build_date WHERE slug = :slug');
        } else {
            $stmt = $this->db->prepare('INSERT INTO `commit` (slug, sha, author, date, message, status, output, build_date) VALUES (:slug, :sha, :author, :date, :message, :status, :output, :build_date)');
        }

        $stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
        $stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
        $stmt->bindValue(':author', $author, \PDO::PARAM_STR);
        $stmt->bindValue(':date', $date->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
        $stmt->bindValue(':message', $message, \PDO::PARAM_STR);
        $stmt->bindValue(':status', 'building', \PDO::PARAM_STR);
        $stmt->bindValue(':output', '', \PDO::PARAM_STR);
        $stmt->bindValue(':build_date', '', \PDO::PARAM_STR);

        if (false === $stmt->execute()) {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException(sprintf('Unable to save commit "%s" from project "%s".', $sha, $project->getName()));
            // @codeCoverageIgnoreEnd
        }

        $commit = new Commit($project, $sha);
        $commit->setAuthor($author);
        $commit->setMessage($message);
        $commit->setDate($date);

        return $commit;
    }
public function initCommit ( Project $ project , $ sha , $ author , \ DateTime $ date , $ message ) { $ stmt = $ this -> db -> prepare ( 'SELECT COUNT(*) FROM `commit` WHERE slug = :slug' ) ; $ stmt -> bindValue ( ':slug' , $ project -> getSlug ( ) , \ PDO :: PARAM_STR ) ; if ( false === $ stmt -> execute ( ) ) { // @codeCoverageIgnoreStart throw new \ RuntimeException ( sprintf ( 'Unable to verify existence of commit "%s" from project "%s".' , $ sha , $ project -> getName ( ) ) ) ; // @codeCoverageIgnoreEnd } if ( $ stmt -> fetchColumn ( 0 ) ) { $ stmt = $ this -> db -> prepare ( 'UPDATE `commit` SET slug = :slug, sha = :sha, author = :author, date = :date, message = :message, status = :status, output = :output, build_date = :build_date WHERE slug = :slug' ) ; } else { $ stmt = $ this -> db -> prepare ( 'INSERT INTO `commit` (slug, sha, author, date, message, status, output, build_date) VALUES (:slug, :sha, :author, :date, :message, :status, :output, :build_date)' ) ; } $ stmt -> bindValue ( ':slug' , $ project -> getSlug ( ) , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':sha' , $ sha , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':author' , $ author , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':date' , $ date -> format ( 'Y-m-d H:i:s' ) , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':message' , $ message , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':status' , 'building' , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':output' , '' , \ PDO :: PARAM_STR ) ; $ stmt -> bindValue ( ':build_date' , '' , \ PDO :: PARAM_STR ) ; if ( false === $ stmt -> execute ( ) ) { // @codeCoverageIgnoreStart throw new \ RuntimeException ( sprintf ( 'Unable to save commit "%s" from project "%s".' , $ sha , $ project -> getName ( ) ) ) ; // @codeCoverageIgnoreEnd } $ commit = new Commit ( $ project , $ sha ) ; $ commit -> setAuthor ( $ author ) ; $ commit -> setMessage ( $ message ) ; $ commit -> setDate ( $ date ) ; return $ commit ; }
Initiate, create and save a new commit.

@param Project   $project The project of the new commit.
@param string    $sha     The hash of the commit.
@param string    $author  The name of the author of the new commit.
@param \DateTime $date    The date the new commit was created originally (e.g. by external resources).
@param string    $message The commit message.

@return Commit The newly created commit.
Initiate create and save a new commit .