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

[Enhancement] refactor to laravel package #17

Merged
merged 9 commits into from
Sep 14, 2024
Merged
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
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
],
"autoload": {
"psr-4": {
"Xray\\AzureStoragePhpSdk\\": "src/",
"Xray\\Tests\\": "tests/"
"Xray\\AzureStoragePhpSdk\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Xray\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"config": {
"allow-plugins": {
Expand Down
110 changes: 55 additions & 55 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions src/Authentication/MicrosoftEntraId.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,40 @@
use Xray\AzureStoragePhpSdk\Concerns\UseCurrentHttpDate;
use Xray\AzureStoragePhpSdk\Contracts\Authentication\Auth;
use Xray\AzureStoragePhpSdk\Contracts\Http\Request;
use Xray\AzureStoragePhpSdk\Exceptions\RequestException;
use Xray\AzureStoragePhpSdk\Exceptions\{RequestException, RequiredFieldException};

final class MicrosoftEntraId implements Auth
{
use UseCurrentHttpDate;

protected string $account;

protected string $directoryId;

protected string $applicationId;

protected string $applicationSecret;

protected ?ClientInterface $client = null;

protected string $token = '';

protected ?DateTime $tokenExpiresAt = null;

public function __construct(
protected string $account,
protected string $directoryId,
protected string $applicationId,
protected string $applicationSecret,
) {
//
/** @param array{account: string, directory: string, application: string, secret: string} $config */
public function __construct(array $config)
{
// @phpstan-ignore-next-line
if (!isset($config['account'], $config['directory'], $config['application'], $config['secret'])) {
$missingParameters = array_diff(['account', 'directory', 'application', 'secret'], array_keys($config));

throw RequiredFieldException::create('Missing required parameters: ' . implode(', ', $missingParameters));
}

$this->account = $config['account'];
$this->directoryId = $config['directory'];
$this->applicationId = $config['application'];
$this->applicationSecret = $config['secret'];
}

public function withRequestClient(ClientInterface $client): self
Expand Down
Loading
Loading