Skip to content
This repository was archived by the owner on Dec 30, 2024. It is now read-only.

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

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
.idea
8 changes: 7 additions & 1 deletion src/Database/Connection.php
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
5 changes: 5 additions & 0 deletions src/Opentelemetry.php
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 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