Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Undefined array key "controller" error and add docblocks #222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ protected function run($query, $bindings, \Closure $callback)
);
}

/**
* Append SQL comments to the underlying query.
*
* @param string $query
* @return string
*/
private function appendSqlComments(string $query): string
{
static $configurationKey = 'google_sqlcommenter.include';
Expand All @@ -52,7 +58,7 @@ private function appendSqlComments(string $query): string
if (config("{$configurationKey}.controller", true) && !empty($action['controller'])) {
$comments['controller'] = explode("@", class_basename($action['controller']))[0];
}
if (config("{$configurationKey}.action", true) && !empty($action and $action['controller'] && str_contains($action['controller'], '@'))) {
if (config("{$configurationKey}.action", true) && !empty($action) && !empty($action['controller']) && str_contains($action['controller'], '@')) {
$comments['action'] = explode("@", class_basename($action['controller']))[1];
}
if (config("{$configurationKey}.route", true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

class Opentelemetry
{
/**
* Get the underlying Opentelemetry values.
*
* @return array
*/
public static function getOpentelemetryValues()
{
$carrier = [];
Expand Down
12 changes: 12 additions & 0 deletions php/sqlcommenter-php/packages/sqlcommenter-laravel/src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

class Utils
{
/**
* Format query comments.
*
* @param array $comments
* @return string
*/
public static function formatComments(array $comments): string
{
if (empty($comments)) {
Expand All @@ -34,6 +40,12 @@ public static function formatComments(array $comments): string
) . "*/";
}

/**
* Encode URL.
*
* @param string $input
* @return string
*/
private static function customUrlEncode(string $input): string
{
$encodedString = urlencode($input);
Expand Down