Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from austinheap/analysis-q5gbDy
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
austinheap committed Nov 16, 2017
2 parents 61f2d3a + f904232 commit 16fc848
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 78 deletions.
14 changes: 6 additions & 8 deletions src/InfluxDbFacade.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
<?php
/**
* src/InfluxDbFacade.php
* src/InfluxDbFacade.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb;

use Illuminate\Support\Facades\Facade;
use Illuminate\Queue\InteractsWithQueue;
use AustinHeap\Database\InfluxDb\Jobs\Write;
use AustinHeap\Database\InfluxDb\Jobs\WritePayload;
use AustinHeap\Database\InfluxDb\Jobs\WritePoints;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Facade;
use AustinHeap\Database\InfluxDb\Jobs\WritePayload;

/**
* Class InfluxDbFacade
*
* @package AustinHeap\Database\InfluxDb
* Class InfluxDbFacade.
*/
class InfluxDbFacade extends Facade
{
Expand Down
26 changes: 12 additions & 14 deletions src/InfluxDbServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?php
/**
* src/InfluxDbServiceProvider.php
* src/InfluxDbServiceProvider.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb;

use AustinHeap\Database\InfluxDb\Logs\Formatter;
use AustinHeap\Database\InfluxDb\Logs\MonologHandler;
use Monolog\Logger;
use Illuminate\Log\Writer;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
use InfluxDB\Client as InfluxClient;
use Illuminate\Support\ServiceProvider;
use AustinHeap\Database\InfluxDb\Logs\Formatter;
use InfluxDB\Client\Exception as ClientException;
use Monolog\Logger;
use AustinHeap\Database\InfluxDb\Logs\MonologHandler;

/**
* Class InfluxDbServiceProvider
*
* @package AustinHeap\Database\InfluxDb
* Class InfluxDbServiceProvider.
*/
class InfluxDbServiceProvider extends ServiceProvider
{
Expand All @@ -31,10 +29,10 @@ class InfluxDbServiceProvider extends ServiceProvider
public function boot(): void
{
$this->publishes([
__DIR__ . '/config/influxdb.php' => config_path('influxdb.php'),
__DIR__.'/config/influxdb.php' => config_path('influxdb.php'),
]);

$this->mergeConfigFrom(__DIR__ . '/config/influxdb.php', 'influxdb');
$this->mergeConfigFrom(__DIR__.'/config/influxdb.php', 'influxdb');

if (config('influxdb.log.monolog', false) === true) {
$handler = new MonologHandler($this->getLoggingLevel());
Expand All @@ -55,12 +53,12 @@ public function register(): void
{
$this->app->singleton('InfluxDb', function ($app) {
try {
$timeout = is_int(config('influxdb.timeout', null)) ? config('influxdb.timeout') : 5;
$timeout = is_int(config('influxdb.timeout', null)) ? config('influxdb.timeout') : 5;
$verifySsl = is_bool(config('influxdb.verify_ssl', null)) ? config('influxdb.verify_ssl') : true;
$protocol = 'influxdb';
$protocol = 'influxdb';

if (in_array(config('influxdb.protocol'), ['https', 'udp'])) {
$protocol = config('influxdb.protocol') . '+' . $protocol;
$protocol = config('influxdb.protocol').'+'.$protocol;
}

$dsn = sprintf('%s://%s:%s@%s:%s/%s',
Expand Down
16 changes: 5 additions & 11 deletions src/Jobs/Job.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* src/Jobs/Job.php
* src/Jobs/Job.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
Expand All @@ -9,20 +9,14 @@

namespace AustinHeap\Database\InfluxDb\Jobs;

use Exception;
use InfluxDb;
use InfluxDB\Point;
use Resque_Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

/**
* Class Job
*
* @package AustinHeap\Database\InfluxDb
* Class Job.
*/
class Job implements ShouldQueue
{
Expand All @@ -32,7 +26,7 @@ class Job implements ShouldQueue
use SerializesModels;

/**
* @var array $args
* @var array
*/
public $args;

Expand Down
14 changes: 6 additions & 8 deletions src/Jobs/Write.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
<?php
/**
* src/Jobs/Write.php
* src/Jobs/Write.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb\Jobs;

use AustinHeap\Database\InfluxDb\InfluxDbServiceProvider;

/**
* Class Write
*
* @package AustinHeap\Database\InfluxDb
* Class Write.
*/
class Write extends Job
{
/**
* @var string|array $payload
* @var string|array
*/
public $payload = null;

/**
* @var array $parameters
* @var array
*/
public $parameters = null;

Expand All @@ -37,7 +35,7 @@ class Write extends Job
public function __construct(array $parameters, $payload)
{
$this->parameters = $parameters;
$this->payload = $payload;
$this->payload = $payload;

parent::__construct(
[
Expand Down
18 changes: 8 additions & 10 deletions src/Jobs/WritePayload.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?php
/**
* src/Jobs/WritePayload.php
* src/Jobs/WritePayload.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb\Jobs;

use AustinHeap\Database\InfluxDb\InfluxDbServiceProvider;

/**
* Class WritePayload
*
* @package AustinHeap\Database\InfluxDb
* Class WritePayload.
*/
class WritePayload extends Job
{
Expand Down Expand Up @@ -49,17 +47,17 @@ class WritePayload extends Job
const PRECISION_HOURS = 'h';

/**
* @var string|array $payload
* @var string|array
*/
public $payload = null;

/**
* @var string $precision
* @var string
*/
public $precision = null;

/**
* @var string|null $retentionPolicy
* @var string|null
*/
public $retentionPolicy = null;

Expand All @@ -72,8 +70,8 @@ class WritePayload extends Job
*/
public function __construct($payload, $precision = self::PRECISION_NANOSECONDS, $retentionPolicy = null)
{
$this->payload = $payload;
$this->precision = $precision;
$this->payload = $payload;
$this->precision = $precision;
$this->retentionPolicy = $retentionPolicy;

parent::__construct(
Expand Down
18 changes: 8 additions & 10 deletions src/Jobs/WritePoints.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?php
/**
* src/Jobs/WritePoints.php
* src/Jobs/WritePoints.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb\Jobs;

use AustinHeap\Database\InfluxDb\InfluxDbServiceProvider;

/**
* Class WritePoints
*
* @package AustinHeap\Database\InfluxDb
* Class WritePoints.
*/
class WritePoints extends Job
{
Expand Down Expand Up @@ -49,17 +47,17 @@ class WritePoints extends Job
const PRECISION_HOURS = 'h';

/**
* @var array $points
* @var array
*/
public $points = null;

/**
* @var string $precision
* @var string
*/
public $precision = null;

/**
* @var string|null $precision
* @var string|null
*/
public $retentionPolicy = null;

Expand All @@ -72,8 +70,8 @@ class WritePoints extends Job
*/
public function __construct(array $points, $precision = self::PRECISION_NANOSECONDS, $retentionPolicy = null)
{
$this->points = $points;
$this->precision = $precision;
$this->points = $points;
$this->precision = $precision;
$this->retentionPolicy = $retentionPolicy;

parent::__construct(
Expand Down
14 changes: 6 additions & 8 deletions src/Logs/Formatter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* src/Logs/Formatter.php
* src/Logs/Formatter.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
Expand All @@ -12,9 +12,7 @@
use Monolog\Formatter\NormalizerFormatter;

/**
* Class Formatter
*
* @package AustinHeap\Database\InfluxDb
* Class Formatter.
*/
class Formatter extends NormalizerFormatter
{
Expand All @@ -37,9 +35,9 @@ public function format(array $record)
*/
protected function prepareMessage(array $record): array
{
$message = [];
$message['name'] = 'Error';
$message['value'] = 1;
$message = [];
$message['name'] = 'Error';
$message['value'] = 1;
$message['timestamp'] = exec('date +%s%N');

if (isset($_SERVER['REMOTE_ADDR'])) {
Expand Down Expand Up @@ -81,7 +79,7 @@ protected function prepareMessage(array $record): array
if (isset($tags) && count($tags)) {
foreach ($tags as $k => $v) {
if (is_numeric($v)) {
$message['fields'][$k] = (int)$v;
$message['fields'][$k] = (int) $v;
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/Logs/MonologHandler.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<?php
/**
* src/Logs/MonologHandler.php
* src/Logs/MonologHandler.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types = 1);
declare(strict_types=1);

namespace AustinHeap\Database\InfluxDb\Logs;

use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
use Monolog\Handler\AbstractProcessingHandler;

/**
* Class MonologHandler
*
* @package AustinHeap\Database\InfluxDb
* Class MonologHandler.
*/
class MonologHandler extends AbstractProcessingHandler
{
Expand Down
2 changes: 1 addition & 1 deletion src/config/influxdb.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* src/config/influxdb.php
* src/config/influxdb.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* src/helpers.php
* src/helpers.php.
*
* @author Austin Heap <me@austinheap.com>
* @version v0.1.2
*/
declare(strict_types=1);

if (!function_exists('influxdb')) {
if (! function_exists('influxdb')) {
/**
* @return \InfluxDB\Client|\InfluxDB\Database
*/
Expand Down

0 comments on commit 16fc848

Please sign in to comment.