Code style fixes.
This commit is contained in:
parent
fb424bfb2b
commit
efbf2650bb
|
@ -3,7 +3,6 @@
|
|||
namespace PHPCensor\Command;
|
||||
|
||||
use PHPCensor\Service\UserService;
|
||||
use b8\Store\Factory;
|
||||
use PHPCensor\Store\UserStore;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -889,7 +889,7 @@ class Project extends Model
|
|||
$default_branch = ($branch == $this->getBranch());
|
||||
foreach($environments['items'] as $environment) {
|
||||
/** @var Environment $environment */
|
||||
if ($default_branch or in_array($branch, $environment->getBranches())) {
|
||||
if ($default_branch || in_array($branch, $environment->getBranches())) {
|
||||
$environments_names[] = $environment->getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace PHPCensor\Plugin;
|
||||
|
||||
use PHPCensor\Builder;
|
||||
use PHPCensor\Helper\Lang;
|
||||
use PHPCensor\Model\Build;
|
||||
use PHPCensor\Plugin;
|
||||
use HipChat\HipChat;
|
||||
|
|
|
@ -1,119 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace PHPCensor\Store;
|
||||
|
||||
use b8\Database;
|
||||
|
||||
/**
|
||||
* Class BuildErrorWriter
|
||||
*/
|
||||
class BuildErrorWriter
|
||||
{
|
||||
/** @var int */
|
||||
protected $build_id;
|
||||
|
||||
/** @var array */
|
||||
protected $errors = [];
|
||||
|
||||
/** @var int */
|
||||
protected $buffer_size;
|
||||
|
||||
/**
|
||||
* BuildErrorWriter constructor.
|
||||
*
|
||||
* @param int $build_id
|
||||
* @param int $buffer_size
|
||||
*/
|
||||
public function __construct($build_id, $buffer_size = 10000)
|
||||
{
|
||||
$this->build_id = $build_id;
|
||||
$this->buffer_size = max((int) $buffer_size, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write error
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $message
|
||||
* @param int $severity
|
||||
* @param string $file
|
||||
* @param int $line_start
|
||||
* @param int $line_end
|
||||
* @param \DateTime $created_date
|
||||
*/
|
||||
public function write($plugin, $message, $severity, $file = null, $line_start = null, $line_end = null, $created_date = null)
|
||||
{
|
||||
if (is_null($created_date)) {
|
||||
$created_date = new \DateTime();
|
||||
}
|
||||
$this->errors[] = array(
|
||||
'plugin' => (string)$plugin,
|
||||
'message' => (string)$message,
|
||||
'severity' => (int)$severity,
|
||||
'file' => !is_null($file) ? (string)$file : null,
|
||||
'line_start' => !is_null($line_start) ? (int)$line_start : null,
|
||||
'line_end' => !is_null($line_end) ? (int)$line_end : null,
|
||||
'created_date' => $created_date->format('Y-m-d H:i:s'),
|
||||
);
|
||||
if (count($this->errors) >= $this->buffer_size) {
|
||||
$this->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if (empty($this->errors)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$insert_values_placeholders = [];
|
||||
$insert_values_data = [];
|
||||
foreach ($this->errors as $i => $error) {
|
||||
$insert_values_placeholders[] = '(
|
||||
:build_id' . $i . ',
|
||||
:plugin' . $i . ',
|
||||
:file' . $i . ',
|
||||
:line_start' . $i . ',
|
||||
:line_end' . $i . ',
|
||||
:severity' . $i . ',
|
||||
:message' . $i . ',
|
||||
:created_date' . $i . '
|
||||
)';
|
||||
$insert_values_data['build_id' . $i] = $this->build_id;
|
||||
$insert_values_data['plugin' . $i] = $error['plugin'];
|
||||
$insert_values_data['file' . $i] = $error['file'];
|
||||
$insert_values_data['line_start' . $i] = $error['line_start'];
|
||||
$insert_values_data['line_end' . $i] = $error['line_end'];
|
||||
$insert_values_data['severity' . $i] = $error['severity'];
|
||||
$insert_values_data['message' . $i] = $error['message'];
|
||||
$insert_values_data['created_date' . $i] = $error['created_date'];
|
||||
}
|
||||
$query = '
|
||||
INSERT INTO {{build_error}} (
|
||||
{{build_id}},
|
||||
{{plugin}},
|
||||
{{file}},
|
||||
{{line_start}},
|
||||
{{line_end}},
|
||||
{{severity}},
|
||||
{{message}},
|
||||
{{created_date}}
|
||||
)
|
||||
VALUES ' . join(', ', $insert_values_placeholders) . '
|
||||
';
|
||||
$stmt = Database::getConnection('write')->prepareCommon($query);
|
||||
$stmt->execute($insert_values_data);
|
||||
$this->errors = [];
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace PHPCensor\Store;
|
||||
|
||||
use b8\Database;
|
||||
|
||||
/**
|
||||
* Class BuildErrorWriter
|
||||
*/
|
||||
class BuildErrorWriter
|
||||
{
|
||||
/** @var int */
|
||||
protected $build_id;
|
||||
|
||||
/** @var array */
|
||||
protected $errors = [];
|
||||
|
||||
/** @var int */
|
||||
protected $buffer_size;
|
||||
|
||||
/**
|
||||
* BuildErrorWriter constructor.
|
||||
*
|
||||
* @param int $build_id
|
||||
* @param int $buffer_size
|
||||
*/
|
||||
public function __construct($build_id, $buffer_size = 10000)
|
||||
{
|
||||
$this->build_id = $build_id;
|
||||
$this->buffer_size = max((int) $buffer_size, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write error
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $message
|
||||
* @param int $severity
|
||||
* @param string $file
|
||||
* @param int $line_start
|
||||
* @param int $line_end
|
||||
* @param \DateTime $created_date
|
||||
*/
|
||||
public function write($plugin, $message, $severity, $file = null, $line_start = null, $line_end = null, $created_date = null)
|
||||
{
|
||||
if (is_null($created_date)) {
|
||||
$created_date = new \DateTime();
|
||||
}
|
||||
$this->errors[] = array(
|
||||
'plugin' => (string)$plugin,
|
||||
'message' => (string)$message,
|
||||
'severity' => (int)$severity,
|
||||
'file' => !is_null($file) ? (string)$file : null,
|
||||
'line_start' => !is_null($line_start) ? (int)$line_start : null,
|
||||
'line_end' => !is_null($line_end) ? (int)$line_end : null,
|
||||
'created_date' => $created_date->format('Y-m-d H:i:s'),
|
||||
);
|
||||
if (count($this->errors) >= $this->buffer_size) {
|
||||
$this->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if (empty($this->errors)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$insert_values_placeholders = [];
|
||||
$insert_values_data = [];
|
||||
foreach ($this->errors as $i => $error) {
|
||||
$insert_values_placeholders[] = '(
|
||||
:build_id' . $i . ',
|
||||
:plugin' . $i . ',
|
||||
:file' . $i . ',
|
||||
:line_start' . $i . ',
|
||||
:line_end' . $i . ',
|
||||
:severity' . $i . ',
|
||||
:message' . $i . ',
|
||||
:created_date' . $i . '
|
||||
)';
|
||||
$insert_values_data['build_id' . $i] = $this->build_id;
|
||||
$insert_values_data['plugin' . $i] = $error['plugin'];
|
||||
$insert_values_data['file' . $i] = $error['file'];
|
||||
$insert_values_data['line_start' . $i] = $error['line_start'];
|
||||
$insert_values_data['line_end' . $i] = $error['line_end'];
|
||||
$insert_values_data['severity' . $i] = $error['severity'];
|
||||
$insert_values_data['message' . $i] = $error['message'];
|
||||
$insert_values_data['created_date' . $i] = $error['created_date'];
|
||||
}
|
||||
$query = '
|
||||
INSERT INTO {{build_error}} (
|
||||
{{build_id}},
|
||||
{{plugin}},
|
||||
{{file}},
|
||||
{{line_start}},
|
||||
{{line_end}},
|
||||
{{severity}},
|
||||
{{message}},
|
||||
{{created_date}}
|
||||
)
|
||||
VALUES ' . join(', ', $insert_values_placeholders) . '
|
||||
';
|
||||
$stmt = Database::getConnection('write')->prepareCommon($query);
|
||||
$stmt->execute($insert_values_data);
|
||||
$this->errors = [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ class BuildStore extends Store
|
|||
$stmt->bindValue(':id', $build->getId(), \PDO::PARAM_INT);
|
||||
$stmt->bindValue(':status_current', $build->getStatus(), \PDO::PARAM_INT);
|
||||
$stmt->bindValue(':status_new', $status, \PDO::PARAM_INT);
|
||||
return ($stmt->execute() and ($stmt->rowCount() == 1));
|
||||
return ($stmt->execute() && ($stmt->rowCount() == 1));
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue