<NME> update.phtml
<BEF> <?php

use PHPCensor\Helper\Lang;
use PHPCensor\Helper\Template;
use PHPCensor\Model\Build;
use PHPCensor\Store\EnvironmentStore;

/**
 * @var Build[]          $builds
 * @var EnvironmentStore $environmentStore
 */

?>
<ul class="timeline">
    <?php $last = new DateTime('-1 Year'); ?>

    <?php
    foreach ($builds as $build):
        $environmentId = $build->getEnvironmentId();
        $environment   = null;
        if ($environmentId) {
            $environmentObject = $environmentStore->getById($environmentId);
            if ($environmentObject) {
                $environment = $environmentObject->getName();
            }
        }

        $branches = $build->getExtra('branches');

        switch ($build->getStatus()) {
            case Build::STATUS_PENDING:
                $updated = $build->getCreateDate();
                $label = Lang::get('pending');
                $color = 'blue blink-item';
                break;

            case Build::STATUS_RUNNING:
                $updated = $build->getStartDate();
                $label = Lang::get('running');
                $color = 'yellow blink-item';
                break;

            case Build::STATUS_SUCCESS:
                $updated = $build->getFinishDate();
                $label = Lang::get('success');
                $color = 'green';
                break;

            case Build::STATUS_FAILED:
                $updated = $build->getFinishDate();
                $label = Lang::get('failed');
                $color = 'red';
                break;
        }

        if (!$updated) {
            $updated = $build->getCreateDate();
        }

        if ($updated->format('Y-m-d') != $last->format('Y-m-d')): $last = $updated;
            ?>
            <li class="time-label">
    <span class="bg-gray">
        <?= $last->format('Y-m-d'); ?>
    </span>
            </li>
        <?php endif; ?>

        <!-- /.timeline-label -->
        <!-- timeline item -->
        <li>
            <i class="fa fa-<?= $build->getProject()->getIcon(); ?> bg-<?= $color; ?>"></i>
            <div class="timeline-item">
                <span class="time"><i class="fa fa-clock-o"></i>
                <?php
                    echo $updated->format('H:i:s');
                    if ($build->getStatus() != Build::STATUS_PENDING) {
                        echo ' &mdash; ' . $build->getDuration(); ?> <?= Lang::get('seconds');
                    }
                ?>
                </span>
                <h3 class="timeline-header">
                    <a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>">
                        #<?= $build->getId(); ?>
                    </a>
                    &mdash;
                    <a href="<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>">

                <div class="timeline-body">
                    <p>
                    <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>
                        <a href="<?= $build->getRemoteBranchLink(); ?>">
                            <i class="fa fa-code-fork"></i>
                            <?= $build->getRemoteBranch(); ?> :
                </h3>

                <div class="timeline-body">
                    <p>
                    <?= $build->getSourceHumanize(); ?> &mdash;
                    <?php if (\in_array($build->getSource(), Build::$pullRequestSources, true)): ?>
                        <a href="<?= $build->getRemoteBranchLink(); ?>">
                            <i class="fa fa-code-fork"></i>
                            <?= $build->getRemoteBranch(); ?> :
                        </a>
                    <?php endif; ?>

                    <a href="<?= $build->getBranchLink(); ?>">
                        <i class="fa fa-code-fork"></i>
                        <?= $build->getBranch(); ?>
                    </a>
                    <?= $branches ? ' + ' . \implode(', ', $branches) : ''; ?>
                    <?php if ($tag = $build->getTag()): ?> /
                        <a href="<?= $build->getTagLink(); ?>">
                            <i class="fa fa-tag"></i>
                            <?= $tag; ?>
                        </a>
                    <?php endif; ?>
                    <?php
                        if (!empty($build->getCommitId())) {
                            echo ' &mdash; ';
                            echo \sprintf(
                                '<a href="%s">%s %s</a>',
                                $build->getCommitLink(),
                                substr($build->getCommitId(), 0, 7),
                                $build->getCommitterEmail() ? ('(' . $build->getCommitterEmail() . ')') : ''
                            );
                            $buildCommitMessage = Template::clean($build->getCommitMessage());
                            if ($buildCommitMessage) {
                                echo ' &mdash; ';
                                echo $buildCommitMessage;
                            }
                        }
                    ?>
                    </p>
                    <?php if (!\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>
                        <p style="color: #999">
                            <?= Lang::get('total_errors'); ?>:
                            <?php if (!\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>
                                <?php $trend = $build->getErrorsTrend(); ?>
                                <?php if (1 === $trend['trend']): ?>
                                    <span class="arrow_trend_positive"><?= (int)$build->getErrorsTotal(); ?> (<?= $trend['delta']; ?>)</span><i class="fa fa-arrow-down arrow_trend_positive"></i>
                                <?php elseif (-1 === $trend['trend']): ?>
                                    <span class="arrow_trend_negative"><?= (int)$build->getErrorsTotal(); ?> (+<?= $trend['delta']; ?>)</span><i class="fa fa-arrow-up arrow_trend_negative"></i>
                                <?php else: ?>
                                    <?= (int)$build->getErrorsTotal(); ?>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if ($newErrorsCount = (int)$build->getErrorsNew()): ?>
                                /
                                <?= Lang::get('new_errors'); ?>:
                                <?php if (0 < $newErrorsCount): ?>
                                    <span class="arrow_trend_negative"><?= $newErrorsCount; ?></span>
                                <?php else: ?>
                                    <?= $newErrorsCount; ?>
                                <?php endif; ?>
                            <?php endif; ?>

                            |
                            <?= Lang::get('test_coverage'); ?>:
                            <?php if (!\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>
                                <?php $trend = $build->getTestCoverageTrend(); ?>
                                <?php if (-1 === $trend['trend']): ?>
                                    <span class="arrow_trend_positive"><?= $build->getTestCoverage(); ?>% (+<?= $trend['delta']; ?>%)</span><i class="fa fa-arrow-up arrow_trend_positive"></i>
                                <?php elseif (1 === $trend['trend']): ?>
                                    <span class="arrow_trend_negative"><?= $build->getTestCoverage(); ?>% (<?= $trend['delta']; ?>%)</span><i class="fa fa-arrow-down arrow_trend_negative"></i>
                                <?php else: ?>
                                    <?= $build->getTestCoverage(); ?>%
                                <?php endif; ?>
                            <?php endif; ?>
                        </p>
                    <?php endif; ?>
                </div>
            </div>
        </li>
        <!-- END timeline item -->

    <?php endforeach; ?>

    <li>
        <i class="fa fa-clock-o"></i>
    </li>
</ul>

<MSG> Fixed views.

<DFF> @@ -88,7 +88,7 @@ use PHPCensor\Model\Build;
 
                 <div class="timeline-body">
                     <p>
-                    <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>
+                    <?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>
                         <a href="<?= $build->getRemoteBranchLink(); ?>">
                             <i class="fa fa-code-fork"></i>
                             <?= $build->getRemoteBranch(); ?> :

{'commit': 'diff --git a/src/View/Build/view.phtml b/src/View/Build/view.phtml\nindex 44c2dcc5..268270cd 100644\n--- a/src/View/Build/view.phtml\n+++ b/src/View/Build/view.phtml\n@@ -34,7 +34,7 @@ use PHPCensor\\Model\\BuildError;\n                     <tr>\n                         <th><?= Lang::get(\'branch\'); ?></th>\n                         <td style="text-align: right">\n-                            <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>\n+                            <?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>\n                                 <a href="<?= $build->getRemoteBranchLink(); ?>">\n                                     <i class="fa fa-code-fork"></i>\n                                     <?= $build->getRemoteBranch(); ?> :\ndiff --git a/src/View/BuildStatus/view.phtml b/src/View/BuildStatus/view.phtml\nindex dc5cd010..3bff6382 100644\n--- a/src/View/BuildStatus/view.phtml\n+++ b/src/View/BuildStatus/view.phtml\n@@ -124,7 +124,7 @@\n                 </td>\n \n                 <td>\n-                    <?php if (in_array($this->getSource(), \\PHPCensor\\Model\\Build::$pullRequestSources, true)): ?>\n+                    <?php if (in_array($build->getSource(), \\PHPCensor\\Model\\Build::$pullRequestSources, true)): ?>\n                         <a href="<?= $build->getRemoteBranchLink(); ?>">\n                             <i class="fa fa-code-fork"></i>\n                             <?= $build->getRemoteBranch(); ?> :\ndiff --git a/src/View/Project/ajax-builds.phtml b/src/View/Project/ajax-builds.phtml\nindex bfc14a76..a1e5bec2 100644\n--- a/src/View/Project/ajax-builds.phtml\n+++ b/src/View/Project/ajax-builds.phtml\n@@ -68,7 +68,7 @@ $branches = $build->getExtra(\'branches\');\n         ?>\n     </td>\n     <td>\n-        <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>\n+        <?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>\n             <a href="<?= $build->getRemoteBranchLink(); ?>">\n                 <i class="fa fa-code-fork"></i>\n                 <?= $build->getRemoteBranch(); ?> :\ndiff --git a/src/View/WidgetLastBuilds/update.phtml b/src/View/WidgetLastBuilds/update.phtml\nindex 79b85a2c..945bd506 100644\n--- a/src/View/WidgetLastBuilds/update.phtml\n+++ b/src/View/WidgetLastBuilds/update.phtml\n@@ -88,7 +88,7 @@ use PHPCensor\\Model\\Build;\n \n                 <div class="timeline-body">\n                     <p>\n-                    <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>\n+                    <?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>\n                         <a href="<?= $build->getRemoteBranchLink(); ?>">\n                             <i class="fa fa-code-fork"></i>\n                             <?= $build->getRemoteBranch(); ?> :\n', 'commit_subject': 'Fixed views.', 'repo_name': 'php-censor/php-censor', 'committer': {'name': 'Dmitry Khomutov', 'email': '38e4dcbed0a1dc9f424ca8ce106203d4427f970f@gmail.com', 'time_sec': '1531649399', 'tz_offset': '420', 'date': {'seconds': '1531649399'}}, 'commit_tree': 'd1fa52535968325b2ef749b9265158f6e73f57d3', 'commit_message': 'Fixed views.\n', 'language_name': 'PHP', 'license': 'bsd-2-clause', 'hunks': '@@ -88,7 +88,7 @@ use PHPCensor\\Model\\Build;\n \n                 <div class="timeline-body">\n                     <p>\n-                    <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>\n+                    <?php if (in_array($build->getSource(), Build::$pullRequestSources, true)): ?>\n                         <a href="<?= $build->getRemoteBranchLink(); ?>">\n                             <i class="fa fa-code-fork"></i>\n                             <?= $build->getRemoteBranch(); ?> :\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/src/View/WidgetLastBuilds/update.phtml', 'tgt_file': 'b/src/View/WidgetLastBuilds/update.phtml', 'file_extension': '.phtml', 'before_file': '<?php\n\nuse PHPCensor\\Helper\\Lang;\nuse PHPCensor\\Helper\\Template;\nuse PHPCensor\\Model\\Build;\nuse PHPCensor\\Store\\EnvironmentStore;\n\n/**\n * @var Build[]          $builds\n * @var EnvironmentStore $environmentStore\n */\n\n?>\n<ul class="timeline">\n    <?php $last = new DateTime(\'-1 Year\'); ?>\n\n    <?php\n    foreach ($builds as $build):\n        $environmentId = $build->getEnvironmentId();\n        $environment   = null;\n        if ($environmentId) {\n            $environmentObject = $environmentStore->getById($environmentId);\n            if ($environmentObject) {\n                $environment = $environmentObject->getName();\n            }\n        }\n\n        $branches = $build->getExtra(\'branches\');\n\n        switch ($build->getStatus()) {\n            case Build::STATUS_PENDING:\n                $updated = $build->getCreateDate();\n                $label = Lang::get(\'pending\');\n                $color = \'blue blink-item\';\n                break;\n\n            case Build::STATUS_RUNNING:\n                $updated = $build->getStartDate();\n                $label = Lang::get(\'running\');\n                $color = \'yellow blink-item\';\n                break;\n\n            case Build::STATUS_SUCCESS:\n                $updated = $build->getFinishDate();\n                $label = Lang::get(\'success\');\n                $color = \'green\';\n                break;\n\n            case Build::STATUS_FAILED:\n                $updated = $build->getFinishDate();\n                $label = Lang::get(\'failed\');\n                $color = \'red\';\n                break;\n        }\n\n        if (!$updated) {\n            $updated = $build->getCreateDate();\n        }\n\n        if ($updated->format(\'Y-m-d\') != $last->format(\'Y-m-d\')): $last = $updated;\n            ?>\n            <li class="time-label">\n    <span class="bg-gray">\n        <?= $last->format(\'Y-m-d\'); ?>\n    </span>\n            </li>\n        <?php endif; ?>\n\n        <!-- /.timeline-label -->\n        <!-- timeline item -->\n        <li>\n            <i class="fa fa-<?= $build->getProject()->getIcon(); ?> bg-<?= $color; ?>"></i>\n            <div class="timeline-item">\n                <span class="time"><i class="fa fa-clock-o"></i>\n                <?php\n                    echo $updated->format(\'H:i:s\');\n                    if ($build->getStatus() != Build::STATUS_PENDING) {\n                        echo \' &mdash; \' . $build->getDuration(); ?> <?= Lang::get(\'seconds\');\n                    }\n                ?>\n                </span>\n                <h3 class="timeline-header">\n                    <a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>">\n                        #<?= $build->getId(); ?>\n                    </a>\n                    &mdash;\n                    <a href="<?= APP_URL; ?>project/view/<?= $build->getProjectId(); ?>">\n\n                <div class="timeline-body">\n                    <p>\n                    <?php if (in_array($this->getSource(), Build::$pullRequestSources, true)): ?>\n                        <a href="<?= $build->getRemoteBranchLink(); ?>">\n                            <i class="fa fa-code-fork"></i>\n                            <?= $build->getRemoteBranch(); ?> :\n                </h3>\n\n                <div class="timeline-body">\n                    <p>\n                    <?= $build->getSourceHumanize(); ?> &mdash;\n                    <?php if (\\in_array($build->getSource(), Build::$pullRequestSources, true)): ?>\n                        <a href="<?= $build->getRemoteBranchLink(); ?>">\n                            <i class="fa fa-code-fork"></i>\n                            <?= $build->getRemoteBranch(); ?> :\n                        </a>\n                    <?php endif; ?>\n\n                    <a href="<?= $build->getBranchLink(); ?>">\n                        <i class="fa fa-code-fork"></i>\n                        <?= $build->getBranch(); ?>\n                    </a>\n                    <?= $branches ? \' + \' . \\implode(\', \', $branches) : \'\'; ?>\n                    <?php if ($tag = $build->getTag()): ?> /\n                        <a href="<?= $build->getTagLink(); ?>">\n                            <i class="fa fa-tag"></i>\n                            <?= $tag; ?>\n                        </a>\n                    <?php endif; ?>\n                    <?php\n                        if (!empty($build->getCommitId())) {\n                            echo \' &mdash; \';\n                            echo \\sprintf(\n                                \'<a href="%s">%s %s</a>\',\n                                $build->getCommitLink(),\n                                substr($build->getCommitId(), 0, 7),\n                                $build->getCommitterEmail() ? (\'(\' . $build->getCommitterEmail() . \')\') : \'\'\n                            );\n                            $buildCommitMessage = Template::clean($build->getCommitMessage());\n                            if ($buildCommitMessage) {\n                                echo \' &mdash; \';\n                                echo $buildCommitMessage;\n                            }\n                        }\n                    ?>\n                    </p>\n                    <?php if (!\\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>\n                        <p style="color: #999">\n                            <?= Lang::get(\'total_errors\'); ?>:\n                            <?php if (!\\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>\n                                <?php $trend = $build->getErrorsTrend(); ?>\n                                <?php if (1 === $trend[\'trend\']): ?>\n                                    <span class="arrow_trend_positive"><?= (int)$build->getErrorsTotal(); ?> (<?= $trend[\'delta\']; ?>)</span><i class="fa fa-arrow-down arrow_trend_positive"></i>\n                                <?php elseif (-1 === $trend[\'trend\']): ?>\n                                    <span class="arrow_trend_negative"><?= (int)$build->getErrorsTotal(); ?> (+<?= $trend[\'delta\']; ?>)</span><i class="fa fa-arrow-up arrow_trend_negative"></i>\n                                <?php else: ?>\n                                    <?= (int)$build->getErrorsTotal(); ?>\n                                <?php endif; ?>\n                            <?php endif; ?>\n\n                            <?php if ($newErrorsCount = (int)$build->getErrorsNew()): ?>\n                                /\n                                <?= Lang::get(\'new_errors\'); ?>:\n                                <?php if (0 < $newErrorsCount): ?>\n                                    <span class="arrow_trend_negative"><?= $newErrorsCount; ?></span>\n                                <?php else: ?>\n                                    <?= $newErrorsCount; ?>\n                                <?php endif; ?>\n                            <?php endif; ?>\n\n                            |\n                            <?= Lang::get(\'test_coverage\'); ?>:\n                            <?php if (!\\in_array($build->getStatus(), [Build::STATUS_PENDING, Build::STATUS_RUNNING], true)): ?>\n                                <?php $trend = $build->getTestCoverageTrend(); ?>\n                                <?php if (-1 === $trend[\'trend\']): ?>\n                                    <span class="arrow_trend_positive"><?= $build->getTestCoverage(); ?>% (+<?= $trend[\'delta\']; ?>%)</span><i class="fa fa-arrow-up arrow_trend_positive"></i>\n                                <?php elseif (1 === $trend[\'trend\']): ?>\n                                    <span class="arrow_trend_negative"><?= $build->getTestCoverage(); ?>% (<?= $trend[\'delta\']; ?>%)</span><i class="fa fa-arrow-down arrow_trend_negative"></i>\n                                <?php else: ?>\n                                    <?= $build->getTestCoverage(); ?>%\n                                <?php endif; ?>\n                            <?php endif; ?>\n                        </p>\n                    <?php endif; ?>\n                </div>\n            </div>\n        </li>\n        <!-- END timeline item -->\n\n    <?php endforeach; ?>\n\n    <li>\n        <i class="fa fa-clock-o"></i>\n    </li>\n</ul>\n', 'message': 'Fixed views.\n', 'author_name': 'Dmitry Khomutov', 'lang': 'phtml'}