Compare commits

...

2 Commits

Author SHA1 Message Date
cee2579d4c
Update 2024-12-16 18:26:40 2024-12-16 18:26:13 +02:00
6cfaf85b5f
Update 2024-09-26 05:32:31 2024-09-26 05:32:05 +02:00
5 changed files with 45 additions and 15 deletions

View File

@ -35,6 +35,14 @@ use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Package Container
*
* @var Container|null
* @since 5.0.3
**/
protected static ?Container $container = null;
/**
* Create a container object
*

View File

@ -1,3 +1,11 @@
/**
* Package Container
*
* @var Container|null
* @since 5.0.3
**/
protected static ?Container $container = null;
/**
* Create a container object
*

View File

@ -13,7 +13,7 @@
```uml
@startuml
class Http << (F,LightGreen) >> #RoyalBlue {
+ __construct(?string $token)
+ __construct(?string $token = null)
+ setToken(string $token) : void
+ getToken() : ?string
}

View File

@ -28,10 +28,10 @@ final class Http extends JoomlaHttp
/**
* The token
*
* @var string
* @var string|null
* @since 3.2.0
*/
protected string $_token_; // to avoid collisions (but allow swapping)
protected ?string $_token_; // to avoid collisions (but allow swapping)
/**
* Constructor.
@ -41,7 +41,7 @@ final class Http extends JoomlaHttp
* @since 3.2.0
* @throws \InvalidArgumentException
**/
public function __construct(?string $token)
public function __construct(?string $token = null)
{
// setup config
$config = [
@ -52,7 +52,7 @@ final class Http extends JoomlaHttp
];
// add the token if given
if (is_string($token))
if (is_string($token) && !empty($token))
{
$config['headers']['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
@ -79,9 +79,16 @@ final class Http extends JoomlaHttp
]
);
// add the token
$headers['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
if (empty($token))
{
unset($headers['Authorization']);
}
else
{
// add the token
$headers['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
}
$this->setOption('headers', $headers);
}

View File

@ -1,10 +1,10 @@
/**
* The token
*
* @var string
* @var string|null
* @since 3.2.0
*/
protected string $_token_; // to avoid collisions (but allow swapping)
protected ?string $_token_; // to avoid collisions (but allow swapping)
/**
* Constructor.
@ -14,7 +14,7 @@
* @since 3.2.0
* @throws \InvalidArgumentException
**/
public function __construct(?string $token)
public function __construct(?string $token = null)
{
// setup config
$config = [
@ -25,7 +25,7 @@
];
// add the token if given
if (is_string($token))
if (is_string($token) && !empty($token))
{
$config['headers']['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
@ -52,9 +52,16 @@
]
);
// add the token
$headers['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
if (empty($token))
{
unset($headers['Authorization']);
}
else
{
// add the token
$headers['Authorization'] = 'token ' . $token;
$this->_token_ = $token;
}
$this->setOption('headers', $headers);
}