Skip to content

Commit

Permalink
update files
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Jan 30, 2024
1 parent 4ba713b commit b848eb6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 60 deletions.
48 changes: 0 additions & 48 deletions src/MakesHttpRequests.php

This file was deleted.

22 changes: 14 additions & 8 deletions src/Socialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Socialite
{
/**
* @var [type]
* @var object
*/
private static $instance;

Expand All @@ -27,7 +27,7 @@ private function __construct()
}

/**
* @return [type]
* Define a static method to get an instance of the class
*/
public static function make()
{
Expand All @@ -52,15 +52,17 @@ public function getProvider(string $name): object
$provider = sprintf('Axm\\Socialite\\Providers\\%sProvider', ucfirst($name));

if (!class_exists($provider)) {
throw new \InvalidArgumentException("Provider $provider not supported.");
throw new \InvalidArgumentException(sprintf('Provider [ %s ] not supported.', $provider));
}

return new $provider($config);
}

/**
* @param string $provider
* @return [type]
* Return an instance of the specified provider's driver.
*
* @param string $provider The name of the provider to return the driver for.
* @return object The driver instance for the specified provider.
*/
public static function driver(string $provider): object
{
Expand All @@ -69,7 +71,8 @@ public static function driver(string $provider): object
}

/**
* @return array
* Returns the configuration array for the specified provider.
* @return array The configuration array for the specified provider.
*/
public function getProviderConfig(): array
{
Expand All @@ -78,13 +81,16 @@ public function getProviderConfig(): array
}

/**
* @return [type]
* Opens and returns the configuration array for the specified provider.
*
* @return array The configuration array for the specified provider.
* @throws \InvalidArgumentException If the configuration file does not exist.
*/
public function openConfig(): array
{
$file = __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
if (!is_file($file)) {
throw new \InvalidArgumentException("The configuration file $file does not exist.");
throw new \InvalidArgumentException(sprintf('The configuration file [ %s ] does not exist.', $file));
}

$config = require($file);
Expand Down
12 changes: 8 additions & 4 deletions src/providers/GoogleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function user()
$code = $this->getCode();
if (!empty($code)) {
try {

$params = $this->getParams($code);

$curl = new Curl();
Expand All @@ -98,6 +97,10 @@ public function user()
}

/**
* This method is used to retrieve the parameters required for the token request.
* It takes in a $code parameter which is the authorization code received from the authorization server.
*
* @param string $code The authorization code received from the authorization server
* @return array
*/
public function getParams($code): array
Expand All @@ -114,6 +117,7 @@ public function getParams($code): array
}

/**
* Define a method to retrieve the 'code' parameter from the request
* @return mixed
*/
public function getCode()
Expand All @@ -124,10 +128,10 @@ public function getCode()
}

/**
* @param string $url
* @return [type]
* Perform a redirect to the given URL
* @param string $url The redirect location
*/
public function makeRedirect(string $url)
protected function makeRedirect(string $url)
{
if (!headers_sent())
app()
Expand Down

0 comments on commit b848eb6

Please sign in to comment.