Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/Commands/DataFilterMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace BinaryBuilds\LaritorClient\Commands;

use Illuminate\Console\GeneratorCommand;

class DataFilterMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:laritor-filter';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a custom data filter for laritor';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'LaritorDataFilter';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/../../stubs/LaritorDataFilter.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Laritor';
}

protected function getArguments()
{
return [];
}

protected function getNameInput()
{
return 'LaritorDataFilter';
}
}
60 changes: 60 additions & 0 deletions src/Commands/DataRedactorMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace BinaryBuilds\LaritorClient\Commands;

use Illuminate\Console\GeneratorCommand;

class DataRedactorMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:laritor-redactor';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a custom data redactor for laritor';

/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'LaritorDataRedactor';

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/../../stubs/LaritorDataRedactor.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Laritor';
}

protected function getArguments()
{
return [];
}

protected function getNameInput()
{
return 'LaritorDataRedactor';
}
}
2 changes: 1 addition & 1 deletion src/Commands/HealthCheckMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function getStub()
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Laritor';
return $rootNamespace.'\Laritor\HealthChecks';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/HealthCheckController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function check(Request $request, $check_type )
case 'queue' : $health_check = app( QueueWorkerHealthCheck::class );break;
default: {

$health_check_class = app()->getNamespace()."BinaryBuilds\\$check_type";
$health_check_class = app()->getNamespace()."Laritor\\HealthChecks\\$check_type";

if (class_exists($health_check_class)) {
$health_check = app( $health_check_class );
Expand Down
8 changes: 4 additions & 4 deletions src/Helpers/HealthCheckHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public function getHealthChecks()
{
$health_checks = [];

if (is_dir(app_path('Laritor'))) {
foreach ((new Finder())->in(app_path('Laritor'))->files() as $health_check) {
if (is_dir(app_path('Laritor/HealthChecks'))) {
foreach ((new Finder())->in(app_path('Laritor/HealthChecks'))->files() as $health_check) {
$name = str_replace(
['/', '.php'],
['\\', ''],
Str::after($health_check->getPathname(), app_path('Laritor').DIRECTORY_SEPARATOR)
Str::after($health_check->getPathname(), app_path('Laritor/HealthChecks').DIRECTORY_SEPARATOR)
);

$class = app()->getNamespace().'Laritor\\'.$name;
$class = app()->getNamespace().'Laritor\\HealthChecks\\'.$name;

$health_checks[] = [
'name' => $class::$name,
Expand Down
6 changes: 5 additions & 1 deletion src/LaritorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace BinaryBuilds\LaritorClient;

use BinaryBuilds\LaritorClient\Commands\DataFilterMakeCommand;
use BinaryBuilds\LaritorClient\Commands\DataRedactorMakeCommand;
use BinaryBuilds\LaritorClient\Override\DefaultOverride;
use BinaryBuilds\LaritorClient\Override\LaritorOverride;
use BinaryBuilds\LaritorClient\Redactor\DataRedactor;
Expand Down Expand Up @@ -45,7 +47,9 @@ public function boot()
HealthCheckMakeCommand::class,
QueueHealthCheckMakeCommand::class,
SyncCommand::class,
SendServerMetricsCommand::class
SendServerMetricsCommand::class,
DataRedactorMakeCommand::class,
DataFilterMakeCommand::class
]);

app(Laritor::class)->started();
Expand Down
112 changes: 112 additions & 0 deletions stubs/LaritorDataFilter.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace {{ namespace }};

use Illuminate\Contracts\Queue\Job;
use Illuminate\Http\Request;
use Illuminate\Notifications\Notification;
use Symfony\Component\Mime\Email;
use BinaryBuilds\LaritorClient\Override\DefaultOverride;

class LaritorDataFilter extends DefaultOverride
{
/**
* @param string $cacheKey
* @return bool
*/
public function recordCacheHit($cacheKey): bool
{
return parent::recordCacheHit($cacheKey);
}

/**
* @param \Throwable $exception
* @return bool
*/
public function recordException($exception): bool
{
return parent::recordException($exception);
}

/**
* @param string $url
* @return bool
*/
public function recordOutboundRequest($url): bool
{
return parent::recordOutboundRequest($url);
}

/**
* @param string $query
* @param int $duration
* @return bool
*/
public function recordQuery($query, $duration): bool
{
return parent::recordQuery($query, $duration);
}

/**
* @param Job $job
* @return bool
*/
public function recordQueuedJob($job): bool
{
return parent::recordQueuedJob($job);
}

/**
* @param Request $request
* @return bool
*/
public function recordRequest($request): bool
{
return parent::recordRequest($request);
}

/**
* @param string $command
* @return bool
*/
public function recordCommandOrScheduledTask($command): bool
{
return parent::recordCommandOrScheduledTask($command);
}

/**
* @return bool
*/
public function recordTaskScheduler(): bool
{
return parent::recordTaskScheduler();
}

/**
* @param Email $message
* @return bool
*/
public function recordMail($message): bool
{
return parent::recordMail($message);
}

/**
* @param mixed $notifiable
* @param Notification $notification
* @return bool
*/
public function recordNotification($notifiable, $notification): bool
{
return parent::recordNotification($notifiable, $notification);
}

/**
* @param Request $request
* @return bool
*/
public function isBot($request): bool
{
return parent::isBot($request);
}
}
39 changes: 39 additions & 0 deletions stubs/LaritorDataRedactor.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace {{ namespace }};

use BinaryBuilds\LaritorClient\Redactor\DefaultRedactor;
use Illuminate\Support\Facades\Auth;

class LaritorDataRedactor extends DefaultRedactor
{
public function redactEmailAddress($address): string
{
return parent::redactEmailAddress($address);
}

public function redactString($text): string
{
return parent::redactString($text);
}

public function redactArrayValue($key, $text): string
{
return parent::redactArrayValue($key, $text);
}

public function redactAuthenticatedUser() : array
{
return parent::redactAuthenticatedUser();
}

public function redactIPAddress($ip): string
{
return parent::redactIPAddress($ip);
}

public function redactUserAgent($userAgent): string
{
return parent::redactUserAgent($userAgent);
}
}