Merge branch 'code-style-refactoring'

This commit is contained in:
Dmitry Khomutov 2018-04-09 20:42:25 +07:00
commit 1acd3dc9b9
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
46 changed files with 263 additions and 249 deletions

View file

@ -57,9 +57,7 @@ class Application
$this->router = new Router($this, $this->request, $this->config); $this->router = new Router($this, $this->request, $this->config);
if (method_exists($this, 'init')) { $this->init();
$this->init();
}
} }
/** /**

View file

@ -2,6 +2,7 @@
namespace PHPCensor\Command; namespace PHPCensor\Command;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Service\UserService; use PHPCensor\Service\UserService;
use PHPCensor\Store\UserStore; use PHPCensor\Store\UserStore;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
@ -58,7 +59,7 @@ class CreateAdminCommand extends Command
// Function to validate email address. // Function to validate email address.
$mailValidator = function ($answer) { $mailValidator = function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) { if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException('Must be a valid email address.'); throw new InvalidArgumentException('Must be a valid email address.');
} }
return $answer; return $answer;

View file

@ -2,6 +2,7 @@
namespace PHPCensor\Command; namespace PHPCensor\Command;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model\Build; use PHPCensor\Model\Build;
use PHPCensor\Service\BuildService; use PHPCensor\Service\BuildService;
use PHPCensor\Store\ProjectStore; use PHPCensor\Store\ProjectStore;
@ -71,7 +72,7 @@ class CreateBuildCommand extends Command
$project = $this->projectStore->getById($projectId); $project = $this->projectStore->getById($projectId);
if (empty($project) || $project->getArchived()) { if (empty($project) || $project->getArchived()) {
throw new \InvalidArgumentException('Project does not exist: ' . $projectId); throw new InvalidArgumentException('Project does not exist: ' . $projectId);
} }
try { try {

View file

@ -6,6 +6,7 @@ use Exception;
use PDO; use PDO;
use PHPCensor\Config; use PHPCensor\Config;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Store\Factory; use PHPCensor\Store\Factory;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;
use PHPCensor\Store\UserStore; use PHPCensor\Store\UserStore;
@ -185,7 +186,7 @@ class InstallCommand extends Command
// Function to validate email address. // Function to validate email address.
$mailValidator = function ($answer) { $mailValidator = function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) { if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) {
throw new \InvalidArgumentException('Must be a valid email address.'); throw new InvalidArgumentException('Must be a valid email address.');
} }
return $answer; return $answer;

View file

@ -1,18 +0,0 @@
<?php
namespace PHPCensor\Exception\HttpException;
use PHPCensor\Exception\HttpException;
class ValidationException extends HttpException
{
/**
* @var integer
*/
protected $errorCode = 400;
/**
* @var string
*/
protected $statusMessage = 'Bad Request';
}

View file

@ -0,0 +1,7 @@
<?php
namespace PHPCensor\Exception;
class InvalidArgumentException extends \InvalidArgumentException
{
}

View file

@ -54,16 +54,6 @@ class Lang
return $string; return $string;
} }
/**
* Output a specific string from the language file.
*
* @param array ...$params
*/
public static function out(...$params)
{
print call_user_func_array(['PHPCensor\Helper\Lang', 'get'], $params);
}
/** /**
* Get the currently active language. * Get the currently active language.
* *

View file

@ -4,6 +4,7 @@ namespace PHPCensor\Http;
use PHPCensor\Application; use PHPCensor\Application;
use PHPCensor\Config; use PHPCensor\Config;
use PHPCensor\Exception\InvalidArgumentException;
class Router class Router
{ {
@ -40,15 +41,16 @@ class Router
} }
/** /**
* @param string $route Route definition * @param string $route Route definition
* @param array $options * @param array $options
* @param callable $callback * @param callable $callback
* @throws \InvalidArgumentException *
* @throws InvalidArgumentException
*/ */
public function register($route, $options = [], $callback = null) public function register($route, $options = [], $callback = null)
{ {
if (!is_callable($callback)) { if (!is_callable($callback)) {
throw new \InvalidArgumentException('$callback must be callable.'); throw new InvalidArgumentException('$callback must be callable.');
} }
array_unshift($this->routes, ['route' => $route, 'callback' => $callback, 'defaults' => $options]); array_unshift($this->routes, ['route' => $route, 'callback' => $callback, 'defaults' => $options]);

View file

@ -2,7 +2,7 @@
namespace PHPCensor; namespace PHPCensor;
use PHPCensor\Exception\HttpException\ValidationException; use PHPCensor\Exception\InvalidArgumentException;
class Model class Model
{ {
@ -29,7 +29,7 @@ class Model
if (is_array($initialData)) { if (is_array($initialData)) {
foreach ($initialData as $index => $item) { foreach ($initialData as $index => $item) {
if (!array_key_exists($index, $this->data)) { if (!array_key_exists($index, $this->data)) {
throw new \InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'Model "%s" doesn\'t have field "%s"', 'Model "%s" doesn\'t have field "%s"',
get_called_class(), get_called_class(),
$index $index
@ -81,12 +81,12 @@ class Model
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
* *
* @throws ValidationException * @throws InvalidArgumentException
*/ */
protected function validateString($name, $value) protected function validateString($name, $value)
{ {
if (!is_string($value) && !is_null($value)) { if (!is_string($value) && !is_null($value)) {
throw new ValidationException('Column "' . $name . '" must be a string.'); throw new InvalidArgumentException('Column "' . $name . '" must be a string.');
} }
} }
@ -94,12 +94,12 @@ class Model
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
* *
* @throws ValidationException * @throws InvalidArgumentException
*/ */
protected function validateInt($name, $value) protected function validateInt($name, $value)
{ {
if (!is_integer($value) && !is_null($value)) { if (!is_integer($value) && !is_null($value)) {
throw new ValidationException('Column "' . $name . '" must be an integer.'); throw new InvalidArgumentException('Column "' . $name . '" must be an integer.');
} }
} }
@ -107,12 +107,12 @@ class Model
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
* *
* @throws ValidationException * @throws InvalidArgumentException
*/ */
protected function validateBoolean($name, $value) protected function validateBoolean($name, $value)
{ {
if (!is_bool($value) && !is_null($value)) { if (!is_bool($value) && !is_null($value)) {
throw new ValidationException('Column "' . $name . '" must be a boolean.'); throw new InvalidArgumentException('Column "' . $name . '" must be a boolean.');
} }
} }
@ -120,12 +120,12 @@ class Model
* @param string $name * @param string $name
* @param mixed $value * @param mixed $value
* *
* @throws ValidationException * @throws InvalidArgumentException
*/ */
protected function validateNotNull($name, $value) protected function validateNotNull($name, $value)
{ {
if (is_null($value)) { if (is_null($value)) {
throw new ValidationException('Column "' . $name . '" must not be null.'); throw new InvalidArgumentException('Column "' . $name . '" must not be null.');
} }
} }
} }

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Model\Base; namespace PHPCensor\Model\Base;
use PHPCensor\Exception\HttpException\ValidationException; use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model; use PHPCensor\Model;
class Build extends Model class Build extends Model
@ -155,7 +155,7 @@ class Build extends Model
/** /**
* @param integer $value * @param integer $value
* *
* @throws ValidationException * @throws InvalidArgumentException
* *
* @return boolean * @return boolean
*/ */
@ -165,7 +165,7 @@ class Build extends Model
$this->validateInt('status', $value); $this->validateInt('status', $value);
if (!in_array($value, $this->allowedStatuses, true)) { if (!in_array($value, $this->allowedStatuses, true)) {
throw new ValidationException( throw new InvalidArgumentException(
'Column "status" must be one of: ' . join(', ', $this->allowedStatuses) . '.' 'Column "status" must be one of: ' . join(', ', $this->allowedStatuses) . '.'
); );
} }
@ -474,7 +474,7 @@ class Build extends Model
/** /**
* @param integer $value * @param integer $value
* *
* @throws ValidationException * @throws InvalidArgumentException
* *
* @return boolean * @return boolean
*/ */
@ -483,7 +483,7 @@ class Build extends Model
$this->validateInt('source', $value); $this->validateInt('source', $value);
if (!in_array($value, $this->allowedSources, true)) { if (!in_array($value, $this->allowedSources, true)) {
throw new ValidationException( throw new InvalidArgumentException(
'Column "source" must be one of: ' . join(', ', $this->allowedSources) . '.' 'Column "source" must be one of: ' . join(', ', $this->allowedSources) . '.'
); );
} }

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Model\Base; namespace PHPCensor\Model\Base;
use PHPCensor\Exception\HttpException\ValidationException; use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model; use PHPCensor\Model;
class Project extends Model class Project extends Model
@ -274,7 +274,7 @@ class Project extends Model
* *
* @return boolean * @return boolean
* *
* @throws ValidationException * @throws InvalidArgumentException
*/ */
public function setType($value) public function setType($value)
{ {
@ -282,7 +282,7 @@ class Project extends Model
$this->validateString('type', $value); $this->validateString('type', $value);
if (!in_array($value, $this->allowedTypes, true)) { if (!in_array($value, $this->allowedTypes, true)) {
throw new ValidationException( throw new InvalidArgumentException(
'Column "type" must be one of: ' . join(', ', $this->allowedTypes) . '.' 'Column "type" must be one of: ' . join(', ', $this->allowedTypes) . '.'
); );
} }

View file

@ -2,6 +2,7 @@
namespace PHPCensor\Plugin\Util; namespace PHPCensor\Plugin\Util;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Plugin; use PHPCensor\Plugin;
use Pimple\Container; use Pimple\Container;
@ -68,11 +69,9 @@ class Factory
* Builds an instance of plugin of class $className. $options will * Builds an instance of plugin of class $className. $options will
* be passed along with any resources registered with the factory. * be passed along with any resources registered with the factory.
* *
* @param $className * @param string $className
* @param array|null $options * @param array|null $options
* *
* @throws \InvalidArgumentException if $className doesn't represent a valid plugin
*
* @return \PHPCensor\Plugin * @return \PHPCensor\Plugin
*/ */
public function buildPlugin($className, $options = []) public function buildPlugin($className, $options = [])
@ -103,10 +102,12 @@ class Factory
} }
/** /**
* @param callable $loader * @param callable $loader
* @param string|null $name * @param string|null $name
* @param string|null $type * @param string|null $type
* @throws \InvalidArgumentException *
* @throws InvalidArgumentException
*
* @internal param mixed $resource * @internal param mixed $resource
*/ */
public function registerResource( public function registerResource(
@ -115,13 +116,13 @@ class Factory
$type = null $type = null
) { ) {
if ($name === null && $type === null) { if ($name === null && $type === null) {
throw new \InvalidArgumentException( throw new InvalidArgumentException(
"Type or Name must be specified" "Type or Name must be specified"
); );
} }
if (!($loader instanceof \Closure)) { if (!($loader instanceof \Closure)) {
throw new \InvalidArgumentException( throw new InvalidArgumentException(
'$loader is expected to be a function' '$loader is expected to be a function'
); );
} }

View file

@ -2,6 +2,8 @@
namespace PHPCensor; namespace PHPCensor;
use PHPCensor\Exception\InvalidArgumentException;
abstract class Store abstract class Store
{ {
/** /**
@ -110,15 +112,14 @@ abstract class Store
* @param Model $obj * @param Model $obj
* @param boolean $saveAllColumns * @param boolean $saveAllColumns
* *
* @throws \RuntimeException * @throws InvalidArgumentException
* @throws \InvalidArgumentException
* *
* @return Model|null * @return Model|null
*/ */
public function save(Model $obj, $saveAllColumns = false) public function save(Model $obj, $saveAllColumns = false)
{ {
if (!($obj instanceof $this->modelName)) { if (!($obj instanceof $this->modelName)) {
throw new \InvalidArgumentException(get_class($obj) . ' is an invalid model type for this store.'); throw new InvalidArgumentException(get_class($obj) . ' is an invalid model type for this store.');
} }
$data = $obj->getDataArray(); $data = $obj->getDataArray();
@ -207,15 +208,14 @@ abstract class Store
/** /**
* @param Model $obj * @param Model $obj
* *
* @throws \RuntimeException * @throws InvalidArgumentException
* @throws \InvalidArgumentException
* *
* @return boolean * @return boolean
*/ */
public function delete(Model $obj) public function delete(Model $obj)
{ {
if (!($obj instanceof $this->modelName)) { if (!($obj instanceof $this->modelName)) {
throw new \InvalidArgumentException(get_class($obj) . ' is an invalid model type for this store.'); throw new InvalidArgumentException(get_class($obj) . ' is an invalid model type for this store.');
} }
$data = $obj->getDataArray(); $data = $obj->getDataArray();
@ -230,14 +230,14 @@ abstract class Store
/** /**
* @param string $field * @param string $field
* *
* @throws \InvalidArgumentException * @throws InvalidArgumentException
* *
* @return string * @return string
*/ */
protected function fieldCheck($field) protected function fieldCheck($field)
{ {
if (empty($field)) { if (empty($field)) {
throw new \InvalidArgumentException('You cannot have an empty field name.'); throw new InvalidArgumentException('You cannot have an empty field name.');
} }
if (strpos($field, '.') === false) { if (strpos($field, '.') === false) {

View file

@ -8,24 +8,40 @@ use PHPCensor\Store\UserStore;
class View class View
{ {
protected $vars = []; /**
protected $isContent = false; * @var array
*/
protected $data = [];
/**
* @var string
*/
protected $viewFile;
/**
* @var string
*/
protected static $extension = 'phtml'; protected static $extension = 'phtml';
/**
* @param string $file
* @param string|null $path
*/
public function __construct($file, $path = null) public function __construct($file, $path = null)
{ {
if ('{@content}' === $file) { if (!self::exists($file, $path)) {
$this->isContent = true; throw new \RuntimeException('View file does not exist: ' . $file);
} else {
if (!self::exists($file, $path)) {
throw new \RuntimeException('View file does not exist: ' . $file);
}
$this->viewFile = self::getViewFile($file, $path);
} }
$this->viewFile = self::getViewFile($file, $path);
} }
/**
* @param string $file
* @param string|null $path
*
* @return string
*/
protected static function getViewFile($file, $path = null) protected static function getViewFile($file, $path = null)
{ {
$viewPath = is_null($path) ? (SRC_DIR . 'View/') : $path; $viewPath = is_null($path) ? (SRC_DIR . 'View/') : $path;
@ -34,6 +50,12 @@ class View
return $fullPath; return $fullPath;
} }
/**
* @param string $file
* @param string|null $path
*
* @return boolean
*/
public static function exists($file, $path = null) public static function exists($file, $path = null)
{ {
if (!file_exists(self::getViewFile($file, $path))) { if (!file_exists(self::getViewFile($file, $path))) {
@ -43,37 +65,50 @@ class View
return true; return true;
} }
public function __isset($var) /**
* @param string $key
*
* @return boolean
*/
public function __isset($key)
{ {
return isset($this->vars[$var]); return isset($this->data[$key]);
} }
public function __get($var) /**
* @param string $key
*
* @return mixed
*/
public function __get($key)
{ {
return $this->vars[$var]; return $this->data[$key];
} }
public function __set($var, $val) /**
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{ {
$this->vars[$var] = $val; $this->data[$key] = $value;
} }
/**
* @return string
*/
public function render() public function render()
{ {
if ($this->isContent) { extract($this->data);
return $this->vars['content'];
} else {
extract($this->vars);
ob_start(); ob_start();
require($this->viewFile); require($this->viewFile);
$html = ob_get_contents(); $html = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $html; return $html;
}
} }
/** /**

View file

@ -1,9 +1,16 @@
<?php <?php
use PHPCensor\Helper\Lang; use PHPCensor\Helper\Lang;
use PHPCensor\Model\Build;
use PHPCensor\Model\BuildError;
/**
* @var Build $build
* @var BuildError[] $errors
*/
$linkTemplate = $build->getFileLinkTemplate(); $linkTemplate = $build->getFileLinkTemplate();
/** @var \PHPCensor\Model\BuildError[] $errors */
foreach ($errors as $error): foreach ($errors as $error):
$link = str_replace('{BASEFILE}', basename($error->getFile()), $linkTemplate); $link = str_replace('{BASEFILE}', basename($error->getFile()), $linkTemplate);
@ -11,7 +18,6 @@ foreach ($errors as $error):
$link = str_replace('{LINE}', $error->getLineStart(), $link); $link = str_replace('{LINE}', $error->getLineStart(), $link);
$link = str_replace('{LINE_END}', $error->getLineEnd(), $link); $link = str_replace('{LINE_END}', $error->getLineEnd(), $link);
?> ?>
<tr> <tr>
<td> <td>
<?php if ($error->getIsNew()): ?> <?php if ($error->getIsNew()): ?>
@ -37,7 +43,5 @@ foreach ($errors as $error):
</a> </a>
</td> </td>
<td class="visible-line-breaks"><?= htmlspecialchars(trim($error->getMessage())); ?></td> <td class="visible-line-breaks"><?= htmlspecialchars(trim($error->getMessage())); ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View file

@ -19,12 +19,18 @@ use PHPCensor\Model\Build;
<h4> <h4>
<?= $build->getProject()->getTitle(); ?> <?= $build->getProject()->getTitle(); ?>
<?php if ($build->getStatus() == \PHPCensor\Model\Build::STATUS_PENDING): ?> <?php if ($build->getStatus() == Build::STATUS_PENDING): ?>
<small class="pull-right"><?php Lang::out('created_x', $build->getCreateDate()->format('H:i')); ?></small> <small class="pull-right">
<?php elseif ($build->getStatus() == \PHPCensor\Model\Build::STATUS_RUNNING): ?> <?= Lang::get('created_x', $build->getCreateDate()->format('H:i')); ?>
<small class="pull-right"><?php Lang::out('started_x', $build->getStartDate()->format('H:i')); ?></small> </small>
<?php elseif ($build->getStatus() == Build::STATUS_RUNNING): ?>
<small class="pull-right">
<?= Lang::get('started_x', $build->getStartDate()->format('H:i')); ?>
</small>
<?php endif; ?> <?php endif; ?>
</h4> </h4>
<p><?php Lang::out('branch_x', $build->getBranch()); ?></p> <p>
<?= Lang::get('branch_x', $build->getBranch()); ?>
</p>
</a> </a>
</li> </li>

View file

@ -15,14 +15,14 @@ use PHPCensor\Model\BuildError;
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"> <h3 class="box-title">
<?php Lang::out('build_details'); ?> <?= Lang::get('build_details'); ?>
</h3> </h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
<table class="table"> <table class="table">
<tr> <tr>
<th><?php Lang::out('project'); ?></th> <th><?= Lang::get('project'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<a href="<?= APP_URL . 'project/view/' . $build->getProjectId(); ?>"> <a href="<?= APP_URL . 'project/view/' . $build->getProjectId(); ?>">
<i class="fa fa-<?= $build->getProject()->getIcon(); ?>"></i> <i class="fa fa-<?= $build->getProject()->getIcon(); ?>"></i>
@ -32,7 +32,7 @@ use PHPCensor\Model\BuildError;
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('branch'); ?></th> <th><?= Lang::get('branch'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?> <?php if (Build::SOURCE_WEBHOOK_PULL_REQUEST === $build->getSource()): ?>
<a href="<?= $build->getRemoteBranchLink(); ?>"> <a href="<?= $build->getRemoteBranchLink(); ?>">
@ -53,7 +53,7 @@ use PHPCensor\Model\BuildError;
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('environment'); ?></th> <th><?= Lang::get('environment'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<?php <?php
$environment = $build->getEnvironment(); $environment = $build->getEnvironment();
@ -63,7 +63,7 @@ use PHPCensor\Model\BuildError;
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('merged_branches'); ?></th> <th><?= Lang::get('merged_branches'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<a href="<?= $build->getBranchLink(); ?>"> <a href="<?= $build->getBranchLink(); ?>">
<i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?> <i class="fa fa-code-fork"></i> <?= $build->getBranch(); ?>
@ -89,20 +89,20 @@ use PHPCensor\Model\BuildError;
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"> <h3 class="box-title">
<?php Lang::out('commit_details'); ?> <?= Lang::get('commit_details'); ?>
</h3> </h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
<table class="table"> <table class="table">
<tr> <tr>
<th><?php Lang::out('build_source'); ?></th> <th><?= Lang::get('build_source'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<?php Lang::out($build->getSourceHumanize()); ?> <?= Lang::get($build->getSourceHumanize()); ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('commit'); ?></th> <th><?= Lang::get('commit'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<a href="<?= $build->getCommitLink(); ?>"> <a href="<?= $build->getCommitLink(); ?>">
<?= substr($build->getCommitId(), 0, 7); ?> <?= substr($build->getCommitId(), 0, 7); ?>
@ -111,14 +111,14 @@ use PHPCensor\Model\BuildError;
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('committer'); ?></th> <th><?= Lang::get('committer'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<?= $build->getCommitterEmail(); ?> <?= $build->getCommitterEmail(); ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('commit_message'); ?></th> <th><?= Lang::get('commit_message'); ?></th>
<td style="text-align: right"> <td style="text-align: right">
<?= htmlspecialchars($build->getCommitMessage()); ?> <?= htmlspecialchars($build->getCommitMessage()); ?>
</td> </td>
@ -132,35 +132,35 @@ use PHPCensor\Model\BuildError;
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"> <h3 class="box-title">
<?php Lang::out('timing'); ?> <?= Lang::get('timing'); ?>
</h3> </h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
<table class="table"> <table class="table">
<tr> <tr>
<th><?php Lang::out('created'); ?></th> <th><?= Lang::get('created'); ?></th>
<td style="text-align: right" class="build-created datetime"> <td style="text-align: right" class="build-created datetime">
<?= ($build->getCreateDate() ? $build->getCreateDate()->format('Y-m-d H:i:s') : ''); ?> <?= ($build->getCreateDate() ? $build->getCreateDate()->format('Y-m-d H:i:s') : ''); ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('started'); ?></th> <th><?= Lang::get('started'); ?></th>
<td style="text-align: right" class="build-started datetime"> <td style="text-align: right" class="build-started datetime">
<?= ($build->getStartDate() ? $build->getStartDate()->format('Y-m-d H:i:s') : ''); ?> <?= ($build->getStartDate() ? $build->getStartDate()->format('Y-m-d H:i:s') : ''); ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('finished'); ?></th> <th><?= Lang::get('finished'); ?></th>
<td style="text-align: right" class="build-finished datetime"> <td style="text-align: right" class="build-finished datetime">
<?= ($build->getFinishDate() ? $build->getFinishDate()->format('Y-m-d H:i:s') : ''); ?> <?= ($build->getFinishDate() ? $build->getFinishDate()->format('Y-m-d H:i:s') : ''); ?>
</td> </td>
</tr> </tr>
<tr> <tr>
<th><?php Lang::out('duration'); ?></th> <th><?= Lang::get('duration'); ?></th>
<td style="text-align: right" class="build-duration duration"> <td style="text-align: right" class="build-duration duration">
<?= $build->getDuration(); ?> <?= Lang::get('seconds'); ?> <?= $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
</td> </td>
@ -289,12 +289,12 @@ use PHPCensor\Model\BuildError;
<table class="errors-table table table-hover"> <table class="errors-table table table-hover">
<thead> <thead>
<tr> <tr>
<th><?php Lang::out('is_new'); ?></th> <th><?= Lang::get('is_new'); ?></th>
<th><?php Lang::out('severity'); ?></th> <th><?= Lang::get('severity'); ?></th>
<th><?php Lang::out('plugin'); ?></th> <th><?= Lang::get('plugin'); ?></th>
<th><?php Lang::out('file'); ?></th> <th><?= Lang::get('file'); ?></th>
<th data-orderable="false"><?php Lang::out('line'); ?></th> <th data-orderable="false"><?= Lang::get('line'); ?></th>
<th data-orderable="false"><?php Lang::out('message'); ?></th> <th data-orderable="false"><?= Lang::get('message'); ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -5,7 +5,7 @@ use PHPCensor\Helper\Lang;
?> ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('group_add_edit'); ?></h3> <h3 class="box-title"><?= Lang::get('group_add_edit'); ?></h3>
</div> </div>
<div class="box-body"> <div class="box-body">

View file

@ -5,7 +5,7 @@ use PHPCensor\Helper\Lang;
?> ?>
<div class="clearfix" style="margin-bottom: 20px;"> <div class="clearfix" style="margin-bottom: 20px;">
<a class="btn btn-success pull-right" href="<?= (APP_URL . 'group/edit'); ?>"> <a class="btn btn-success pull-right" href="<?= (APP_URL . 'group/edit'); ?>">
<?php Lang::out('group_add'); ?> <?= Lang::get('group_add'); ?>
</a> </a>
</div> </div>
@ -13,8 +13,8 @@ use PHPCensor\Helper\Lang;
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th><?php Lang::out('group_title'); ?></th> <th><?= Lang::get('group_title'); ?></th>
<th><?php Lang::out('group_count'); ?></th> <th><?= Lang::get('group_count'); ?></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -25,13 +25,13 @@ use PHPCensor\Helper\Lang;
<td><?= count($group['projects']); ?></td> <td><?= count($group['projects']); ?></td>
<td> <td>
<div class="btn-group btn-group-right"> <div class="btn-group btn-group-right">
<a class="btn btn-default btn-sm" href="<?= APP_URL; ?>group/edit/<?= $group['id']; ?>"><?php Lang::out('group_edit'); ?></a> <a class="btn btn-default btn-sm" href="<?= APP_URL; ?>group/edit/<?= $group['id']; ?>"><?= Lang::get('group_edit'); ?></a>
<?php if($this->getUser()->getIsAdmin() && (!count($group['projects']))): ?> <?php if($this->getUser()->getIsAdmin() && (!count($group['projects']))): ?>
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="<?= APP_URL; ?>group/delete/<?= $group['id']; ?>" class="delete-group"><?php Lang::out('group_delete'); ?></a></li> <li><a href="<?= APP_URL; ?>group/delete/<?= $group['id']; ?>" class="delete-group"><?= Lang::get('group_delete'); ?></a></li>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</div> </div>

View file

@ -11,7 +11,7 @@ use PHPCensor\Model\Build;
<?php if(empty($builds) || !count($builds)): ?> <?php if(empty($builds) || !count($builds)): ?>
<tr class=""> <tr class="">
<td colspan="6"><?php Lang::out('no_builds_yet'); ?></td> <td colspan="6"><?= Lang::get('no_builds_yet'); ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
@ -52,7 +52,7 @@ $branches = $build->getExtra('branches');
<td><a href="<?= APP_URL ?>build/view/<?= $build->getId(); ?>">#<?= str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td> <td><a href="<?= APP_URL ?>build/view/<?= $build->getId(); ?>">#<?= str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
<td><span class='label label-<?= $subcls ?>'><?= $status ?></span></td> <td><span class='label label-<?= $subcls ?>'><?= $status ?></span></td>
<td><?= $build->getCreateDate()->format('Y-m-d H:i:s'); ?></td> <td><?= $build->getCreateDate()->format('Y-m-d H:i:s'); ?></td>
<td><?php Lang::out($build->getSourceHumanize()); ?></td> <td><?= Lang::get($build->getSourceHumanize()); ?></td>
<td class="hidden-md hidden-sm hidden-xs"> <td class="hidden-md hidden-sm hidden-xs">
<?php <?php
if (!empty($build->getCommitId())) { if (!empty($build->getCommitId())) {
@ -100,13 +100,13 @@ $branches = $build->getExtra('branches');
</td> </td>
<td> <td>
<div class="btn-group btn-group-right"> <div class="btn-group btn-group-right">
<a class="btn btn-default btn-sm" href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>"><?php Lang::out('view'); ?></a> <a class="btn btn-default btn-sm" href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>"><?= Lang::get('view'); ?></a>
<?php if($this->getUser()->getIsAdmin()): ?> <?php if($this->getUser()->getIsAdmin()): ?>
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="<?= APP_URL; ?>build/delete/<?= $build->getId(); ?>" class="delete-build"><?php Lang::out('delete_build'); ?></a></li> <li><a href="<?= APP_URL; ?>build/delete/<?= $build->getId(); ?>" class="delete-build"><?= Lang::get('delete_build'); ?></a></li>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</div> </div>

View file

@ -24,7 +24,7 @@
<div class="col-sm-8"> <div class="col-sm-8">
<div class="box "> <div class="box ">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('project_details'); ?></h3> <h3 class="box-title"><?= Lang::get('project_details'); ?></h3>
</div> </div>
<div class="box-body"> <div class="box-body">
@ -37,7 +37,7 @@
<div class="col-sm-4"> <div class="col-sm-4">
<div class="box"> <div class="box">
<div class="box-body"> <div class="box-body">
<p><?php Lang::out('public_key_help'); ?></p> <p><?= Lang::get('public_key_help'); ?></p>
<textarea style="width: 90%; height: 150px;"><?= $key; ?></textarea> <textarea style="width: 90%; height: 150px;"><?= $key; ?></textarea>
</div> </div>
</div> </div>

View file

@ -17,11 +17,11 @@ use PHPCensor\Helper\Lang;
<div class="clearfix" style="margin-bottom: 20px;"> <div class="clearfix" style="margin-bottom: 20px;">
<a class="btn btn-default" href="<?= APP_URL . 'project/edit/' . $project->getId(); ?>"> <a class="btn btn-default" href="<?= APP_URL . 'project/edit/' . $project->getId(); ?>">
<?php Lang::out('edit_project'); ?> <?= Lang::get('edit_project'); ?>
</a> </a>
<a class="btn btn-danger" id="delete-project"> <a class="btn btn-danger" id="delete-project">
<?php Lang::out('delete_project'); ?> <?= Lang::get('delete_project'); ?>
</a> </a>
<?php <?php
@ -32,30 +32,30 @@ use PHPCensor\Helper\Lang;
<?php if ($this->getUser()->getIsAdmin()): ?> <?php if ($this->getUser()->getIsAdmin()): ?>
<?php if (!empty($environment)): ?> <?php if (!empty($environment)): ?>
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment, 'debug' => 1]); ?>"> <a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment, 'debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?> <?= Lang::get('build_now_debug'); ?>
</a> </a>
<?php elseif (!empty($branch)): ?> <?php elseif (!empty($branch)): ?>
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch, 'debug' => 1]); ?>"> <a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch, 'debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?> <?= Lang::get('build_now_debug'); ?>
</a> </a>
<?php else: ?> <?php else: ?>
<a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['debug' => 1]); ?>"> <a class="btn btn-danger" href="<?= $build_url . '?' . http_build_query(['debug' => 1]); ?>">
<?php Lang::out('build_now_debug'); ?> <?= Lang::get('build_now_debug'); ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
<?php if (!empty($environment)): ?> <?php if (!empty($environment)): ?>
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment]); ?>"> <a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'environment', 'id' => $environment]); ?>">
<?php Lang::out('build_now'); ?> <?= Lang::get('build_now'); ?>
</a> </a>
<?php elseif (!empty($branch)): ?> <?php elseif (!empty($branch)): ?>
<a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch]); ?>"> <a class="btn btn-success" href="<?= $build_url . '?' . http_build_query(['type' => 'branch', 'id' => $branch]); ?>">
<?php Lang::out('build_now'); ?> <?= Lang::get('build_now'); ?>
</a> </a>
<?php else: ?> <?php else: ?>
<a class="btn btn-success" href="<?= $build_url; ?>"> <a class="btn btn-success" href="<?= $build_url; ?>">
<?php Lang::out('build_now'); ?> <?= Lang::get('build_now'); ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
@ -63,16 +63,16 @@ use PHPCensor\Helper\Lang;
<div class="btn-group branch-btn pull-right"> <div class="btn-group branch-btn pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?php if (!empty($environment)) { <?php if (!empty($environment)) {
Lang::out('environment_x', $environment); echo Lang::get('environment_x', $environment);
} elseif (!empty($branch)) { } elseif (!empty($branch)) {
Lang::out('branch_x', $branch); echo Lang::get('branch_x', $branch);
} else { } else {
Lang::out('all'); echo Lang::get('all');
} ?>&nbsp;&nbsp;<span class="caret"></span> } ?>&nbsp;&nbsp;<span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>"><?php Lang::out('all'); ?></a></li> <li><a href="<?= APP_URL; ?>project/view/<?= $project->getId(); ?>"><?= Lang::get('all'); ?></a></li>
<li class="divider"></li> <li class="divider"></li>
<?php if(!empty($environments)): ?> <?php if(!empty($environments)): ?>
@ -103,20 +103,20 @@ use PHPCensor\Helper\Lang;
<div class="col-lg-9 col-md-8 col-sm-8"> <div class="col-lg-9 col-md-8 col-sm-8">
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('builds'); ?> (<?= $total; ?>)</h3> <h3 class="box-title"><?= Lang::get('builds'); ?> (<?= $total; ?>)</h3>
</div> </div>
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th><?php Lang::out('id'); ?></th> <th><?= Lang::get('id'); ?></th>
<th><?php Lang::out('status'); ?></th> <th><?= Lang::get('status'); ?></th>
<th><?php Lang::out('date'); ?></th> <th><?= Lang::get('date'); ?></th>
<th><?php Lang::out('build_source'); ?></th> <th><?= Lang::get('build_source'); ?></th>
<th class="hidden-md hidden-sm hidden-xs"><?php Lang::out('commit'); ?></th> <th class="hidden-md hidden-sm hidden-xs"><?= Lang::get('commit'); ?></th>
<th><?php Lang::out('branch'); ?></th> <th><?= Lang::get('branch'); ?></th>
<th><?php Lang::out('environment'); ?></th> <th><?= Lang::get('environment'); ?></th>
<th><?php Lang::out('duration'); ?></th> <th><?= Lang::get('duration'); ?></th>
<th><?php Lang::out('new_errors'); ?></th> <th><?= Lang::get('new_errors'); ?></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -162,7 +162,7 @@ use PHPCensor\Helper\Lang;
<?php if (in_array($project->getType(), ['github', 'gitlab', 'bitbucket'])): ?> <?php if (in_array($project->getType(), ['github', 'gitlab', 'bitbucket'])): ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h4 class="box-title"><?php Lang::out('webhooks'); ?></h4> <h4 class="box-title"><?= Lang::get('webhooks'); ?></h4>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i> <i class="fa fa-minus"></i>
@ -174,18 +174,18 @@ use PHPCensor\Helper\Lang;
<?php switch($project->getType()) { <?php switch($project->getType()) {
case 'github': case 'github':
$url = APP_URL . 'webhook/github/' . $project->getId(); $url = APP_URL . 'webhook/github/' . $project->getId();
Lang::out('webhooks_help_github', $project->getReference()); echo Lang::get('webhooks_help_github', $project->getReference());
break; break;
case 'gitlab': case 'gitlab':
$url = APP_URL. 'webhook/gitlab/' . $project->getId(); $url = APP_URL. 'webhook/gitlab/' . $project->getId();
Lang::out('webhooks_help_gitlab'); echo Lang::get('webhooks_help_gitlab');
break; break;
case 'bitbucket': case 'bitbucket':
case 'bitbucket-hg': case 'bitbucket-hg':
$url = APP_URL . 'webhook/bitbucket/' . $project->getId(); $url = APP_URL . 'webhook/bitbucket/' . $project->getId();
Lang::out('webhooks_help_bitbucket', $project->getReference()); echo Lang::get('webhooks_help_bitbucket', $project->getReference());
break; break;
} ?> } ?>
<br><br><strong style="word-wrap: break-word;"><?= $url; ?></strong> <br><br><strong style="word-wrap: break-word;"><?= $url; ?></strong>
@ -196,7 +196,7 @@ use PHPCensor\Helper\Lang;
<?php if ($project->getSshPublicKey()): ?> <?php if ($project->getSshPublicKey()): ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('public_key'); ?></h3> <h3 class="box-title"><?= Lang::get('public_key'); ?></h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i> <i class="fa fa-minus"></i>

View file

@ -1,12 +1,12 @@
<?php use PHPCensor\Helper\Lang; ?> <?php use PHPCensor\Helper\Lang; ?>
<?php if (isset($emailed)): ?> <?php if (isset($emailed)): ?>
<p class="alert alert-success" style="margin-bottom: 0"> <p class="alert alert-success" style="margin-bottom: 0">
<?php Lang::out('reset_emailed'); ?> <?= Lang::get('reset_emailed'); ?>
</p> </p>
<?php else: ?> <?php else: ?>
<?php if (empty($error)): ?> <?php if (empty($error)): ?>
<div class="" style="margin-bottom: 15px;"> <div class="" style="margin-bottom: 15px;">
<?php Lang::out('reset_header'); ?> <?= Lang::get('reset_header'); ?>
</div> </div>
<?php else: ?> <?php else: ?>
<div class="alert alert-danger"> <div class="alert alert-danger">
@ -16,12 +16,12 @@
<div class=""> <div class="">
<form class="form" action="<?= APP_URL; ?>session/forgot-password" method="POST"> <form class="form" action="<?= APP_URL; ?>session/forgot-password" method="POST">
<div class="form-group"> <div class="form-group">
<label for="email"><?php Lang::out('reset_email_address'); ?></label> <label for="email"><?= Lang::get('reset_email_address'); ?></label>
<input id="email" name="email" class="form-control" required> <input id="email" name="email" class="form-control" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<input class="btn btn-success" type="submit" value="<?php Lang::out('reset_send_email'); ?>"> <input class="btn btn-success" type="submit" value="<?= Lang::get('reset_send_email'); ?>">
</div> </div>
</form> </form>
</div> </div>

View file

@ -1,9 +1,9 @@
<?php use PHPCensor\Helper\Lang; ?> <?php use PHPCensor\Helper\Lang; ?>
<?php if($failed): ?> <?php if($failed): ?>
<p class="alert alert-danger"><?php Lang::out('login_error'); ?></p> <p class="alert alert-danger"><?= Lang::get('login_error'); ?></p>
<?php endif; ?> <?php endif; ?>
<?= $form; ?> <?= $form; ?>
<a style="margin-top: -22px;" class="pull-right" href="<?= APP_URL; ?>session/forgot-password"> <a style="margin-top: -22px;" class="pull-right" href="<?= APP_URL; ?>session/forgot-password">
<?php Lang::out('forgotten_password_link'); ?> <?= Lang::get('forgotten_password_link'); ?>
</a> </a>

View file

@ -1,18 +1,18 @@
<?php use PHPCensor\Helper\Lang; ?> <?php use PHPCensor\Helper\Lang; ?>
<?php if (empty($error)): ?> <?php if (empty($error)): ?>
<div class="box-header"> <div class="box-header">
<?php Lang::out('reset_enter_password'); ?> <?= Lang::get('reset_enter_password'); ?>
</div> </div>
<div class="box-body"> <div class="box-body">
<form class="form" action="<?= APP_URL; ?>session/reset-password/<?= $id; ?>/<?= $key; ?>" method="POST"> <form class="form" action="<?= APP_URL; ?>session/reset-password/<?= $id; ?>/<?= $key; ?>" method="POST">
<div class="form-group"> <div class="form-group">
<label for="password"><?php Lang::out('reset_new_password'); ?></label> <label for="password"><?= Lang::get('reset_new_password'); ?></label>
<input type="password" id="password" name="password" class="form-control" required> <input type="password" id="password" name="password" class="form-control" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<input class="btn btn-success" type="submit" value="<?php Lang::out('reset_change_password'); ?>"> <input class="btn btn-success" type="submit" value="<?= Lang::get('reset_change_password'); ?>">
</div> </div>
</form> </form>
</div> </div>

View file

@ -7,7 +7,7 @@ $user = $this->getUser();
?> ?>
<div class="clearfix" style="margin-bottom: 20px;"> <div class="clearfix" style="margin-bottom: 20px;">
<div class="pull-right btn-group"> <div class="pull-right btn-group">
<a class="btn btn-success" href="<?= APP_URL; ?>user/add"><?php Lang::out('add_user'); ?></a> <a class="btn btn-success" href="<?= APP_URL; ?>user/add"><?= Lang::get('add_user'); ?></a>
</div> </div>
</div> </div>
@ -18,9 +18,9 @@ $user = $this->getUser();
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th><?php Lang::out('email_address'); ?></th> <th><?= Lang::get('email_address'); ?></th>
<th><?php Lang::out('name'); ?></th> <th><?= Lang::get('name'); ?></th>
<th><?php Lang::out('is_admin'); ?></th> <th><?= Lang::get('is_admin'); ?></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -47,12 +47,12 @@ $user = $this->getUser();
<td> <td>
<?php if($user->getIsAdmin()): ?> <?php if($user->getIsAdmin()): ?>
<div class="btn-group btn-group-right"> <div class="btn-group btn-group-right">
<a class="btn btn-default btn-sm" href="<?= APP_URL; ?>user/edit/<?= $user->getId(); ?>"><?php Lang::out('edit'); ?></a> <a class="btn btn-default btn-sm" href="<?= APP_URL; ?>user/edit/<?= $user->getId(); ?>"><?= Lang::get('edit'); ?></a>
<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="<?= APP_URL; ?>user/delete/<?= $user->getId(); ?>" class="delete-user"><?php Lang::out('delete_user'); ?></a></li> <li><a href="<?= APP_URL; ?>user/delete/<?= $user->getId(); ?>" class="delete-user"><?= Lang::get('delete_user'); ?></a></li>
</ul> </ul>
</div> </div>
<?php endif; ?> <?php endif; ?>

View file

@ -4,12 +4,12 @@ use PHPCensor\Helper\Lang;
?> ?>
<?php if (isset($updated)): ?> <?php if (isset($updated)): ?>
<p class="alert alert-success"><?php Lang::out('your_details_updated'); ?></p> <p class="alert alert-success"><?= Lang::get('your_details_updated'); ?></p>
<?php endif; ?> <?php endif; ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('update_your_details'); ?></h3> <h3 class="box-title"><?= Lang::get('update_your_details'); ?></h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<?= $form; ?> <?= $form; ?>

View file

@ -112,7 +112,7 @@ foreach($projects as $project):
<i class="fa fa-lock"></i> <i class="fa fa-lock"></i>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php Lang::out('view_project'); ?> (<?= $counts[$project->getId()]; ?>) <i class="fa fa-arrow-circle-right"></i> <?= Lang::get('view_project'); ?> (<?= $counts[$project->getId()]; ?>) <i class="fa fa-arrow-circle-right"></i>
</a> </a>
<?php for ($idx=0; $idx < 5; $idx++) { <?php for ($idx=0; $idx < 5; $idx++) {

View file

@ -111,7 +111,7 @@ if ($buildCount > 0) {
<i class="fa fa-lock"></i> <i class="fa fa-lock"></i>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php Lang::out('view_project'); ?> (<?= $counts; ?>) <i class="fa fa-arrow-circle-right"></i> <?= Lang::get('view_project'); ?> (<?= $counts; ?>) <i class="fa fa-arrow-circle-right"></i>
</a> </a>
<?php for ($idx=0; $idx < 5; $idx++) { <?php for ($idx=0; $idx < 5; $idx++) {

View file

@ -2,4 +2,4 @@
use PHPCensor\Helper\Lang; use PHPCensor\Helper\Lang;
?><div class=""><?= Lang::out('no_build_errors') ?></div> ?><div class=""><?= Lang::get('no_build_errors') ?></div>

View file

@ -5,7 +5,7 @@ use PHPCensor\Helper\Lang;
?> ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?= Lang::out('projects_with_build_errors') ?></h3> <h3 class="box-title"><?= Lang::get('projects_with_build_errors') ?></h3>
</div> </div>
<div class="box-body" id="dashboard-build-errors"> <div class="box-body" id="dashboard-build-errors">
<?= $projects ?> <?= $projects ?>

View file

@ -99,7 +99,7 @@ foreach($builds as $project_id => $project_envs):
<?= $project->getTitle(); ?> <?= $project->getTitle(); ?>
</a> </a>
<?php if (!empty($environment)) { ?> <?php if (!empty($environment)) { ?>
<sup title="<?php Lang::out('environment'); ?>"><?= $environment ?></sup> <sup title="<?= Lang::get('environment'); ?>"><?= $environment ?></sup>
<?php } ?> <?php } ?>
</h3> </h3>
@ -119,7 +119,7 @@ foreach($builds as $project_id => $project_envs):
<i class="fa fa-lock"></i> <i class="fa fa-lock"></i>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php Lang::out('view_project'); ?> <i class="fa fa-arrow-circle-right"></i> <?= Lang::get('view_project'); ?> <i class="fa fa-arrow-circle-right"></i>
</a> </a>
<?php for ($idx=0; $idx < 5; $idx++) { <?php for ($idx=0; $idx < 5; $idx++) {

View file

@ -5,7 +5,7 @@ use PHPCensor\Helper\Lang;
?> ?>
<div class="box"> <div class="box">
<div class="box-header"> <div class="box-header">
<h3 class="box-title"><?php Lang::out('latest_builds'); ?></h3> <h3 class="box-title"><?= Lang::get('latest_builds'); ?></h3>
</div> </div>
<div class="box-body" id="timeline-box"> <div class="box-body" id="timeline-box">
<?= $timeline ?> <?= $timeline ?>

View file

@ -75,13 +75,13 @@ use PHPCensor\Model\Build;
<span><?= $environment; ?></span> <span><?= $environment; ?></span>
&mdash; &mdash;
<a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>"> <a href="<?= APP_URL; ?>build/view/<?= $build->getId(); ?>">
<?php Lang::out('build'); ?> #<?= $build->getId(); ?> <?= Lang::get('build'); ?> #<?= $build->getId(); ?>
</a> </a>
&mdash; &mdash;
<?php Lang::out($build->getSourceHumanize()); ?> <?= Lang::get($build->getSourceHumanize()); ?>
<?php if ($newErrorsCount = $build->getNewErrorsCount()): ?> <?php if ($newErrorsCount = $build->getNewErrorsCount()): ?>
&mdash; &mdash;
<?php Lang::out('new_errors'); ?>: <?= Lang::get('new_errors'); ?>:
<?= $newErrorsCount; ?> <?= $newErrorsCount; ?>
<?php endif; ?> <?php endif; ?>
</h3> </h3>

View file

@ -39,9 +39,9 @@ $user = $this->getUser();
var LANGUAGE = '<?= Lang::getLanguage(); ?>'; var LANGUAGE = '<?= Lang::getLanguage(); ?>';
<?php if (defined('JSON_UNESCAPED_UNICODE')): ?> <?php if (defined('JSON_UNESCAPED_UNICODE')): ?>
var STRINGS = <?= json_encode(Lang::getStrings(), JSON_UNESCAPED_UNICODE); ?>; var STRINGS = <?= json_encode(Lang::getStrings(), JSON_UNESCAPED_UNICODE); ?>;
<?php else: ?> <?php else: ?>
var STRINGS = <?= json_encode(Lang::getStrings()); ?>; var STRINGS = <?= json_encode(Lang::getStrings()); ?>;
<?php endif; ?> <?php endif; ?>
</script> </script>
@ -58,7 +58,7 @@ $user = $this->getUser();
<nav class="navbar navbar-static-top" role="navigation"> <nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button--> <!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only"><?php Lang::out('toggle_navigation'); ?></span> <span class="sr-only"><?= Lang::get('toggle_navigation'); ?></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -72,7 +72,7 @@ $user = $this->getUser();
<span class="label label-info app-pending-count"></span> <span class="label label-info app-pending-count"></span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header"><?php Lang::out('n_builds_pending', 0); ?></li> <li class="header"><?= Lang::get('n_builds_pending', 0); ?></li>
<li> <li>
<ul class="menu app-pending-list"> <ul class="menu app-pending-list">
</ul> </ul>
@ -86,7 +86,7 @@ $user = $this->getUser();
<span class="label label-warning app-running-count"></span> <span class="label label-warning app-running-count"></span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header"><?php Lang::out('n_builds_running', 0); ?></li> <li class="header"><?= Lang::get('n_builds_running', 0); ?></li>
<li> <li>
<ul class="menu app-running-list"> <ul class="menu app-running-list">
</ul> </ul>
@ -113,10 +113,10 @@ $user = $this->getUser();
<!-- Menu Footer--> <!-- Menu Footer-->
<li class="user-footer"> <li class="user-footer">
<div class="pull-left"> <div class="pull-left">
<a href="<?= APP_URL; ?>user/profile" class="btn btn-default btn-flat"><?php Lang::out('edit_profile'); ?></a> <a href="<?= APP_URL; ?>user/profile" class="btn btn-default btn-flat"><?= Lang::get('edit_profile'); ?></a>
</div> </div>
<div class="pull-right"> <div class="pull-right">
<a href="<?= APP_URL; ?>session/logout" class="btn btn-default btn-flat"><?php Lang::out('sign_out'); ?></a> <a href="<?= APP_URL; ?>session/logout" class="btn btn-default btn-flat"><?= Lang::get('sign_out'); ?></a>
</div> </div>
</li> </li>
</ul> </ul>
@ -138,7 +138,7 @@ $user = $this->getUser();
<img src="https://www.gravatar.com/avatar/<?= md5($user->getEmail()); ?>?d=mm" class="img-circle" alt="<?= $user->getName(); ?>" /> <img src="https://www.gravatar.com/avatar/<?= md5($user->getEmail()); ?>?d=mm" class="img-circle" alt="<?= $user->getName(); ?>" />
</div> </div>
<div class="pull-left info"> <div class="pull-left info">
<p><?php Lang::out('hello_name', $user->getName()); ?></p> <p><?= Lang::get('hello_name', $user->getName()); ?></p>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
@ -147,7 +147,7 @@ $user = $this->getUser();
<ul class="sidebar-menu"> <ul class="sidebar-menu">
<li<?= (array_key_exists('archived', $_GET) ? '' : ' class="active"'); ?>> <li<?= (array_key_exists('archived', $_GET) ? '' : ' class="active"'); ?>>
<a href="<?= APP_URL; ?>"> <a href="<?= APP_URL; ?>">
<i class="fa fa-dashboard"></i> <span><?php Lang::out('dashboard'); ?></span> <i class="fa fa-dashboard"></i> <span><?= Lang::get('dashboard'); ?></span>
</a> </a>
</li> </li>
@ -155,23 +155,23 @@ $user = $this->getUser();
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
<span><?php Lang::out('admin_options'); ?></span> <span><?= Lang::get('admin_options'); ?></span>
<i class="fa fa-angle-left pull-right"></i> <i class="fa fa-angle-left pull-right"></i>
</a> </a>
<ul class="treeview-menu"> <ul class="treeview-menu">
<li> <li>
<a href="<?= APP_URL; ?>project/add"> <a href="<?= APP_URL; ?>project/add">
<i class="fa fa-angle-double-right"></i> <?php Lang::out('add_project'); ?> <i class="fa fa-angle-double-right"></i> <?= Lang::get('add_project'); ?>
</a> </a>
</li> </li>
<li> <li>
<a href="<?= APP_URL; ?>group"> <a href="<?= APP_URL; ?>group">
<i class="fa fa-angle-double-right"></i> <?php Lang::out('project_groups'); ?> <i class="fa fa-angle-double-right"></i> <?= Lang::get('project_groups'); ?>
</a> </a>
</li> </li>
<li> <li>
<a href="<?= APP_URL; ?>user"> <a href="<?= APP_URL; ?>user">
<i class="fa fa-angle-double-right"></i> <?php Lang::out('manage_users'); ?> <i class="fa fa-angle-double-right"></i> <?= Lang::get('manage_users'); ?>
</a> </a>
</li> </li>
</ul> </ul>
@ -204,7 +204,7 @@ $user = $this->getUser();
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
<i class="fa fa-archive"></i> <span><?php Lang::out('archived_menu'); ?></span> <i class="fa fa-archive"></i> <span><?= Lang::get('archived_menu'); ?></span>
<i class="fa fa-angle-left pull-right"></i> <i class="fa fa-angle-left pull-right"></i>
</a> </a>

View file

@ -2,7 +2,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title><?php Lang::out('log_in_to_app'); ?></title> <title><?= Lang::get('log_in_to_app'); ?></title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">

View file

@ -3,6 +3,7 @@
namespace Tests\PHPCensor\Command; namespace Tests\PHPCensor\Command;
use PHPCensor\Command\CreateBuildCommand; use PHPCensor\Command\CreateBuildCommand;
use PHPCensor\Exception\InvalidArgumentException;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\Console\Tester\CommandTester;
@ -68,7 +69,7 @@ class CreateBuildCommandTest extends \PHPUnit\Framework\TestCase
} }
/** /**
* @expectedException \InvalidArgumentException * @expectedException InvalidArgumentException
*/ */
public function testExecuteWithUnknownProjectId() public function testExecuteWithUnknownProjectId()
{ {

View file

@ -73,14 +73,4 @@ class HttpExceptionTest extends \PHPUnit\Framework\TestCase
self::assertTrue($ex->getStatusMessage() == 'Internal Server Error'); self::assertTrue($ex->getStatusMessage() == 'Internal Server Error');
} }
} }
public function testValidationException()
{
try {
throw new HttpException\ValidationException('Test');
} catch (HttpException $ex) {
self::assertTrue($ex->getErrorCode() == 400);
self::assertTrue($ex->getStatusMessage() == 'Bad Request');
}
}
} }

View file

@ -81,7 +81,7 @@ class BuildTest extends TestCase
$result = $build->setStatus(Build::STATUS_FAILED); $result = $build->setStatus(Build::STATUS_FAILED);
self::assertEquals(false, $result); self::assertEquals(false, $result);
self::expectException('\PHPCensor\Exception\HttpException\ValidationException'); self::expectException('\PHPCensor\Exception\InvalidArgumentException');
$build->setStatus(10); $build->setStatus(10);
} }
@ -230,7 +230,7 @@ class BuildTest extends TestCase
$result = $build->setSource(Build::SOURCE_WEBHOOK_PULL_REQUEST); $result = $build->setSource(Build::SOURCE_WEBHOOK_PULL_REQUEST);
self::assertEquals(false, $result); self::assertEquals(false, $result);
self::expectException('\PHPCensor\Exception\HttpException\ValidationException'); self::expectException('\PHPCensor\Exception\InvalidArgumentException');
$build->setSource(20); $build->setSource(20);
} }

View file

@ -138,7 +138,7 @@ class ProjectTest extends TestCase
$result = $project->setType('git'); $result = $project->setType('git');
self::assertEquals(false, $result); self::assertEquals(false, $result);
self::expectException('\PHPCensor\Exception\HttpException\ValidationException'); self::expectException('\PHPCensor\Exception\InvalidArgumentException');
$project->setType('invalid-type'); $project->setType('invalid-type');
} }

View file

@ -2,7 +2,7 @@
namespace Tests\PHPCensor\Model; namespace Tests\PHPCensor\Model;
use PHPCensor\Exception\HttpException\ValidationException; use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model\Build; use PHPCensor\Model\Build;
/** /**
@ -49,7 +49,7 @@ class BuildTest extends \PHPUnit\Framework\TestCase
'branch' => 'dev', 'branch' => 'dev',
'unknown' => 'unknown', 'unknown' => 'unknown',
]); ]);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'Model "PHPCensor\Model\Build" doesn\'t have field "unknown"', 'Model "PHPCensor\Model\Build" doesn\'t have field "unknown"',
$e->getMessage() $e->getMessage()
@ -65,7 +65,7 @@ class BuildTest extends \PHPUnit\Framework\TestCase
try { try {
$build->setLog([]); $build->setLog([]);
} catch (ValidationException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'Column "log" must be a string.', 'Column "log" must be a string.',
$e->getMessage() $e->getMessage()
@ -77,7 +77,7 @@ class BuildTest extends \PHPUnit\Framework\TestCase
try { try {
$build->setSource('5'); $build->setSource('5');
} catch (ValidationException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'Column "source" must be an integer.', 'Column "source" must be an integer.',
$e->getMessage() $e->getMessage()
@ -86,7 +86,7 @@ class BuildTest extends \PHPUnit\Framework\TestCase
try { try {
$build->setId(null); $build->setId(null);
} catch (ValidationException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'Column "id" must not be null.', 'Column "id" must not be null.',
$e->getMessage() $e->getMessage()

View file

@ -2,7 +2,7 @@
namespace Tests\PHPCensor\Model; namespace Tests\PHPCensor\Model;
use PHPCensor\Exception\HttpException\ValidationException; use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Model; use PHPCensor\Model;
@ -20,7 +20,7 @@ class ProjectTest extends \PHPUnit\Framework\TestCase
try { try {
$project->setArchived('true'); $project->setArchived('true');
} catch (ValidationException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'Column "archived" must be a boolean.', 'Column "archived" must be a boolean.',
$e->getMessage() $e->getMessage()

View file

@ -34,13 +34,15 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
public function testRegisterResourceThrowsExceptionWithoutTypeAndName() public function testRegisterResourceThrowsExceptionWithoutTypeAndName()
{ {
$this->setExpectedException('InvalidArgumentException', 'Type or Name must be specified'); self::expectException('\PHPCensor\Exception\InvalidArgumentException');
self::expectExceptionMessage('Type or Name must be specified');
$this->testedFactory->registerResource($this->resourceLoader, null, null); $this->testedFactory->registerResource($this->resourceLoader, null, null);
} }
public function testRegisterResourceThrowsExceptionIfLoaderIsntFunction() public function testRegisterResourceThrowsExceptionIfLoaderIsntFunction()
{ {
$this->setExpectedException('InvalidArgumentException', '$loader is expected to be a function'); self::expectException('\PHPCensor\Exception\InvalidArgumentException');
self::expectExceptionMessage('$loader is expected to be a function');
$this->testedFactory->registerResource(["dummy"], "TestName", "TestClass"); $this->testedFactory->registerResource(["dummy"], "TestName", "TestClass");
} }
@ -53,10 +55,8 @@ class FactoryTest extends \PHPUnit\Framework\TestCase {
public function testBuildPluginThrowsExceptionIfMissingResourcesForRequiredArg() public function testBuildPluginThrowsExceptionIfMissingResourcesForRequiredArg()
{ {
$this->setExpectedException( self::expectException('\DomainException');
'DomainException', self::expectExceptionMessage('Unsatisfied dependency: requiredArgument');
'Unsatisfied dependency: requiredArgument'
);
$pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg'); $pluginClass = $this->getFakePluginClassName('ExamplePluginWithSingleRequiredArg');
$plugin = $this->testedFactory->buildPlugin($pluginClass); $plugin = $this->testedFactory->buildPlugin($pluginClass);

View file

@ -4,6 +4,7 @@ namespace Tests\PHPCensor;
use PHPCensor\Config; use PHPCensor\Config;
use PHPCensor\Database; use PHPCensor\Database;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Store\Factory; use PHPCensor\Store\Factory;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;
@ -177,7 +178,7 @@ class StoreMysqlTest extends \PHPUnit_Extensions_Database_TestCase
try { try {
$data = $testStore->getWhere(['' => 0], 100, 0, ['id' => 'ASC']); $data = $testStore->getWhere(['' => 0], 100, 0, ['id' => 'ASC']);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals('You cannot have an empty field name.', $e->getMessage()); self::assertEquals('You cannot have an empty field name.', $e->getMessage());
} }
@ -233,7 +234,7 @@ class StoreMysqlTest extends \PHPUnit_Extensions_Database_TestCase
$model->setId(1); $model->setId(1);
$testStore->save($model); $testStore->save($model);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'PHPCensor\Model\Project is an invalid model type for this store.', 'PHPCensor\Model\Project is an invalid model type for this store.',
$e->getMessage() $e->getMessage()
@ -258,7 +259,7 @@ class StoreMysqlTest extends \PHPUnit_Extensions_Database_TestCase
$model->setId(1); $model->setId(1);
$testStore->delete($model); $testStore->delete($model);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'PHPCensor\Model\Project is an invalid model type for this store.', 'PHPCensor\Model\Project is an invalid model type for this store.',
$e->getMessage() $e->getMessage()

View file

@ -4,6 +4,7 @@ namespace Tests\PHPCensor;
use PHPCensor\Config; use PHPCensor\Config;
use PHPCensor\Database; use PHPCensor\Database;
use PHPCensor\Exception\InvalidArgumentException;
use PHPCensor\Store\Factory; use PHPCensor\Store\Factory;
use PHPCensor\Model\Project; use PHPCensor\Model\Project;
use PHPCensor\Model\ProjectGroup; use PHPCensor\Model\ProjectGroup;
@ -164,7 +165,7 @@ class StorePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
try { try {
$data = $testStore->getWhere(['' => 0], 100, 0, ['id' => 'ASC']); $data = $testStore->getWhere(['' => 0], 100, 0, ['id' => 'ASC']);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals('You cannot have an empty field name.', $e->getMessage()); self::assertEquals('You cannot have an empty field name.', $e->getMessage());
} }
@ -228,7 +229,7 @@ class StorePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
$model->setId(1); $model->setId(1);
$testStore->save($model); $testStore->save($model);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'PHPCensor\Model\Project is an invalid model type for this store.', 'PHPCensor\Model\Project is an invalid model type for this store.',
$e->getMessage() $e->getMessage()
@ -253,7 +254,7 @@ class StorePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase
$model->setId(1); $model->setId(1);
$testStore->delete($model); $testStore->delete($model);
} catch (\InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
self::assertEquals( self::assertEquals(
'PHPCensor\Model\Project is an invalid model type for this store.', 'PHPCensor\Model\Project is an invalid model type for this store.',
$e->getMessage() $e->getMessage()

View file

@ -29,11 +29,4 @@ class ViewTest extends \PHPUnit\Framework\TestCase
self::assertFalse(isset($view->what)); self::assertFalse(isset($view->what));
self::assertTrue($view->render() == 'Hello World'); self::assertTrue($view->render() == 'Hello World');
} }
public function testUserViewVars()
{
$view = new View('{@content}');
$view->content = 'World';
self::assertTrue($view->render() == 'World');
}
} }