Skip to content

Commit

Permalink
Adds random phrase generator
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Apr 23, 2024
1 parent 410cb72 commit a39765a
Show file tree
Hide file tree
Showing 10 changed files with 631 additions and 111 deletions.
10 changes: 6 additions & 4 deletions app/Http/Controllers/CallAction.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace App\Http\Controllers;
Expand All @@ -11,6 +12,7 @@
use App\Modules\Smtp\Common as SmtpActions;
use App\Modules\VarDump\Common as VarDumpActions;
use App\Modules\Inspector\Common as InspectorActions;
use App\RandomPhraseGenerator;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -53,7 +55,7 @@ class CallAction extends Controller
'ray_logs:exception' => 'monologException',
];

public function __invoke(Request $request)
public function __invoke(Request $request, RandomPhraseGenerator $generator)
{
$this->setUpFaker();

Expand All @@ -65,22 +67,22 @@ public function __invoke(Request $request)

foreach ($this->setUpMap as $a => $method) {
if (Str::startsWith($action, $a)) {
call_user_func([$this, $method]);
call_user_func([$this, $method], $generator);
break;
}
}

foreach ($this->actionsMap as $a => $method) {
if ($action === $a) {
call_user_func([$this, $method]);
call_user_func([$this, $method], $generator);
return 'ok';
}
}

$method = Str::studly(Str::replace(':', '_', $action));

if (method_exists($this, $method)) {
call_user_func([$this, $method]);
call_user_func([$this, $method], $generator);
return 'ok';
}

Expand Down
6 changes: 3 additions & 3 deletions app/Modules/Inspector/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@

trait Common
{
public function setUpInspector()
public function setUpInspector(): void
{
ray()->disable();
}

/** @test */
public function inspectorRequest()
public function inspectorRequest(): void
{
$request = Request::create('/inspector');

Route::dispatch($request);
}

/** @test */
public function inspectorCommand()
public function inspectorCommand(): void
{
Artisan::call('inspector:test');
}
Expand Down
44 changes: 23 additions & 21 deletions app/Modules/Monolog/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,98 @@

namespace App\Modules\Monolog;

use App\RandomPhraseGenerator;

trait Common
{
public function setUpSocketMonolog()
public function setUpSocketMonolog(): void
{
logger()->setDefaultDriver('socket');
ray()->disable();
}

public function setUpSlackMonolog()
public function setUpSlackMonolog(): void
{
logger()->setDefaultDriver('slack');
ray()->disable();
}

public function setUpRayLogger()
public function setUpRayLogger(): void
{
logger()->setDefaultDriver('null');
}

/**
* @test
*/
function monologDebug()
function monologDebug(RandomPhraseGenerator $generator): void
{
logger()->debug('Hello debug', [
logger()->debug($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologInfo()
function monologInfo(RandomPhraseGenerator $generator): void
{
logger()->info('Hello info', [
logger()->info($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologWarning()
function monologWarning(RandomPhraseGenerator $generator): void
{
logger()->warning('Hello warning', [
logger()->warning($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologError()
function monologError(RandomPhraseGenerator $generator): void
{
logger()->error('Hello error', [
logger()->error($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologCritical()
function monologCritical(RandomPhraseGenerator $generator): void
{
logger()->critical('Hello critical', [
logger()->critical($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologNotice()
function monologNotice(RandomPhraseGenerator $generator): void
{
logger()->notice('Hello notice', [
logger()->notice($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologAlert()
function monologAlert(RandomPhraseGenerator $generator): void
{
logger()->alert('Hello alert', [
logger()->alert($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologEmergency()
function monologEmergency(RandomPhraseGenerator $generator): void
{
logger()->emergency('Hello emergency', [
logger()->emergency($generator->generate('Buggregator'), [
'foo' => 'bar'
]);
}

/** @test */
function monologException()
function monologException(RandomPhraseGenerator $generator): void
{
try {
throw new \Exception('Something went wrong');
throw new \Exception($generator->generateException('Buggregator'));
} catch (\Throwable $e) {
logger()->error($e);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Modules/Profiler/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

trait Common
{
public function setupProfiler()
public function setupProfiler(): void
{
ray()->disable();
logger()->setDefaultDriver('null');
}

/** @test */
function profilerReport()
function profilerReport(): void
{
}
}
Loading

0 comments on commit a39765a

Please sign in to comment.