ParsesSearchPath.php
TLDR
This file provides the ParsesSearchPath
trait, which contains a method called parseSearchPath
. The trait is used to parse the Postgres "search_path" configuration value into an array.
Methods
parseSearchPath
This method takes a string, an array, or null as the input and parses the Postgres "search_path" configuration value into an array. If the input is a string, the method uses regular expressions to extract the relevant values. The method then trims any excess characters from the resulting array elements and returns the parsed search path as an array.
<?php
namespace Illuminate\Database\Concerns;
trait ParsesSearchPath
{
/**
* Parse the Postgres "search_path" configuration value into an array.
*
* @param string|array|null $searchPath
* @return array
*/
protected function parseSearchPath($searchPath)
{
if (is_string($searchPath)) {
preg_match_all('/[^\s,"\']+/', $searchPath, $matches);
$searchPath = $matches[0];
}
return array_map(function ($schema) {
return trim($schema, '\'"');
}, $searchPath ?? []);
}
}