mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Automated formatting changes
This commit is contained in:
parent
e98d649876
commit
793efdfb45
|
|
@ -30,7 +30,7 @@ class HttpBasicAuthOptionProvider extends PostAuthOptionProvider
|
||||||
$encoded = \base64_encode($params['client_id'] . ':' . $params['client_secret']);
|
$encoded = \base64_encode($params['client_id'] . ':' . $params['client_secret']);
|
||||||
unset($params['client_id'], $params['client_secret']);
|
unset($params['client_id'], $params['client_secret']);
|
||||||
|
|
||||||
$options = parent::getAccessTokenOptions($method, $params);
|
$options = parent::getAccessTokenOptions($method, $params);
|
||||||
$options['headers']['Authorization'] = 'Basic ' . $encoded;
|
$options['headers']['Authorization'] = 'Basic ' . $encoded;
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\Auth\OAuth2\OptionProvider;
|
namespace phpOMS\Auth\OAuth2\OptionProvider;
|
||||||
|
|
||||||
use phpOMS\System\MimeType;
|
|
||||||
use phpOMS\Message\Http\RequestMethod;
|
use phpOMS\Message\Http\RequestMethod;
|
||||||
|
use phpOMS\System\MimeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider class.
|
* Provider class.
|
||||||
|
|
@ -31,7 +31,7 @@ class PostAuthOptionProvider implements OptionProviderInterface
|
||||||
public function getAccessTokenOptions(string $method, array $params) : array
|
public function getAccessTokenOptions(string $method, array $params) : array
|
||||||
{
|
{
|
||||||
$options = [
|
$options = [
|
||||||
'headers' => ['content-type' => MimeType::M_POST]
|
'headers' => ['content-type' => MimeType::M_POST],
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($method === RequestMethod::POST) {
|
if ($method === RequestMethod::POST) {
|
||||||
|
|
|
||||||
|
|
@ -126,12 +126,12 @@ abstract class ProviderAbstract
|
||||||
$this->state = $options['state'];
|
$this->state = $options['state'];
|
||||||
|
|
||||||
$options += [
|
$options += [
|
||||||
'response_type' => 'code',
|
'response_type' => 'code',
|
||||||
'approval_prompt' => 'auto',
|
'approval_prompt' => 'auto',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (\is_array($options['scope'])) {
|
if (\is_array($options['scope'])) {
|
||||||
$options['scope'] = implode($this->getScopeSeparator(), $options['scope']);
|
$options['scope'] = \implode($this->getScopeSeparator(), $options['scope']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$options['redirect_uri'] ??= $this->redirectUri;
|
$options['redirect_uri'] ??= $this->redirectUri;
|
||||||
|
|
@ -147,9 +147,9 @@ abstract class ProviderAbstract
|
||||||
|
|
||||||
public function getauthorizationUrl(array $options = []) : string
|
public function getauthorizationUrl(array $options = []) : string
|
||||||
{
|
{
|
||||||
$base = $this->getBaseAuthorizationUrl();
|
$base = $this->getBaseAuthorizationUrl();
|
||||||
$params = $this->getAuthorizationParameters($options);
|
$params = $this->getAuthorizationParameters($options);
|
||||||
$query = $this->getAuthorizationQuery($params);
|
$query = $this->getAuthorizationQuery($params);
|
||||||
|
|
||||||
return UriFactory::build($base . '?' . $query);
|
return UriFactory::build($base . '?' . $query);
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ abstract class ProviderAbstract
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
header('Location: ' . $url);
|
\header('Location: ' . $url);
|
||||||
exit;
|
exit;
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
@ -199,8 +199,8 @@ abstract class ProviderAbstract
|
||||||
|
|
||||||
protected function getAccessTokenRequest(array $params) : HttpRequest
|
protected function getAccessTokenRequest(array $params) : HttpRequest
|
||||||
{
|
{
|
||||||
$method = $this->getAccessTokenMethod();
|
$method = $this->getAccessTokenMethod();
|
||||||
$url = $this->getAccessTokenUrl($params);
|
$url = $this->getAccessTokenUrl($params);
|
||||||
$options = $this->getoptionProvider->getAccessTokenOptions($this->getAccessTokenMethod(), $params);
|
$options = $this->getoptionProvider->getAccessTokenOptions($this->getAccessTokenMethod(), $params);
|
||||||
|
|
||||||
return $this->createRequest($method, $url, null, $options);
|
return $this->createRequest($method, $url, null, $options);
|
||||||
|
|
@ -212,17 +212,17 @@ abstract class ProviderAbstract
|
||||||
$grant = \is_string($grant) ? $this->grantFactory->getGrant($grant) : $this->verifyGrant();
|
$grant = \is_string($grant) ? $this->grantFactory->getGrant($grant) : $this->verifyGrant();
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'client_id' => $this->clientId,
|
'client_id' => $this->clientId,
|
||||||
'client_secret' => $this->clientSecret,
|
'client_secret' => $this->clientSecret,
|
||||||
'redirect_uri' => $this->redirectUri,
|
'redirect_uri' => $this->redirectUri,
|
||||||
];
|
];
|
||||||
|
|
||||||
$params = $grant->prepareRequestParameters($params, $options);
|
$params = $grant->prepareRequestParameters($params, $options);
|
||||||
$request = $this->getAccessTokenRequest($params);
|
$request = $this->getAccessTokenRequest($params);
|
||||||
$response = $this->getParsedResponse($request);
|
$response = $this->getParsedResponse($request);
|
||||||
|
|
||||||
$prepared = $this->prepareAccessTokenResponse($response);
|
$prepared = $this->prepareAccessTokenResponse($response);
|
||||||
$token = $this->createAccessToken($prepared, $grant);
|
$token = $this->createAccessToken($prepared, $grant);
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ abstract class ProviderAbstract
|
||||||
public function getParsedResponse(HttpRequest $request)
|
public function getParsedResponse(HttpRequest $request)
|
||||||
{
|
{
|
||||||
$response = $request->rest();
|
$response = $request->rest();
|
||||||
$parsed = $this->parseResponse($response);
|
$parsed = $this->parseResponse($response);
|
||||||
|
|
||||||
$this->checkResponse($response, $parsed);
|
$this->checkResponse($response, $parsed);
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ abstract class ProviderAbstract
|
||||||
protected function parseResponse(HttpResponse $response) : array
|
protected function parseResponse(HttpResponse $response) : array
|
||||||
{
|
{
|
||||||
$content = $response->getBody();
|
$content = $response->getBody();
|
||||||
$type = \implode(';', (array) $response->getHeader()->get('Content-Type'));
|
$type = \implode(';', (array) $response->getHeader()->get('Content-Type'));
|
||||||
|
|
||||||
if (\stripos($type, 'urlencoded') !== false) {
|
if (\stripos($type, 'urlencoded') !== false) {
|
||||||
\parse_str($content, $parsed);
|
\parse_str($content, $parsed);
|
||||||
|
|
@ -267,7 +267,9 @@ abstract class ProviderAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function checkResponse(HttpResponse $response, $data) : void; // todo: consider to make bool
|
abstract protected function checkResponse(HttpResponse $response, $data) : void;
|
||||||
|
|
||||||
|
// todo: consider to make bool
|
||||||
|
|
||||||
protected function prepareAccessTokenResponse(array $result) : array
|
protected function prepareAccessTokenResponse(array $result) : array
|
||||||
{
|
{
|
||||||
|
|
@ -294,8 +296,8 @@ abstract class ProviderAbstract
|
||||||
|
|
||||||
protected function fetchResourceOwnerDetails(AccessToken $token)
|
protected function fetchResourceOwnerDetails(AccessToken $token)
|
||||||
{
|
{
|
||||||
$url = $this->getResourceOwnerDetailsUrl($token);
|
$url = $this->getResourceOwnerDetailsUrl($token);
|
||||||
$request = $this->getAuthenticatedRequest(RequestMethod::GET, $url, $token);
|
$request = $this->getAuthenticatedRequest(RequestMethod::GET, $url, $token);
|
||||||
$response = $this->getParsedResponse($request);
|
$response = $this->getParsedResponse($request);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
|
||||||
|
|
@ -194,8 +194,6 @@ class Mail
|
||||||
*/
|
*/
|
||||||
protected ?\DateTime $messageDate = null;
|
protected ?\DateTime $messageDate = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should confirm reading
|
* Should confirm reading
|
||||||
*
|
*
|
||||||
|
|
@ -1408,8 +1406,8 @@ class Mail
|
||||||
|
|
||||||
public function clearAddresses() : void
|
public function clearAddresses() : void
|
||||||
{
|
{
|
||||||
$this->to = [];
|
$this->to = [];
|
||||||
$this->cc = [];
|
$this->cc = [];
|
||||||
$this->bcc = [];
|
$this->bcc = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1455,7 +1453,7 @@ class Mail
|
||||||
list($name, $value) = \explode(':', $name, 2);
|
list($name, $value) = \explode(':', $name, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = \trim($name);
|
$name = \trim($name);
|
||||||
$value = \trim($value);
|
$value = \trim($value);
|
||||||
|
|
||||||
if (empty($name) || \strbrk($name . $value, "\r\n") !== false) {
|
if (empty($name) || \strbrk($name . $value, "\r\n") !== false) {
|
||||||
|
|
@ -1475,7 +1473,6 @@ class Mail
|
||||||
|
|
||||||
public function msgHtml(string $message, string $baseDir = '') : string
|
public function msgHtml(string $message, string $baseDir = '') : string
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ class CustomerValueTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEqualsWithDelta(30000, CustomerValue::getSimpleCLV($margin, $retention, 0.0), 0.1);
|
self::assertEqualsWithDelta(30000, CustomerValue::getSimpleCLV($margin, $retention, 0.0), 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox The monthly recurring revenue (MRR) is correctly calculated
|
* @testdox The monthly recurring revenue (MRR) is correctly calculated
|
||||||
* @group framework
|
* @group framework
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@ class MetricsTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testBerrysCustomerProfits() : void
|
public function testBerrysCustomerProfits() : void
|
||||||
{
|
{
|
||||||
$acquisitionCost = 30.0;
|
$acquisitionCost = 30.0;
|
||||||
$customers = 100000;
|
$customers = 100000;
|
||||||
$ongoingMarketingCustomer = 10;
|
$ongoingMarketingCustomer = 10;
|
||||||
$revenueCustomer = 100;
|
$revenueCustomer = 100;
|
||||||
$cogsCustomer = 50;
|
$cogsCustomer = 50;
|
||||||
$discountRate = 0.15;
|
$discountRate = 0.15;
|
||||||
|
|
||||||
self::assertEqualsWithDelta(
|
self::assertEqualsWithDelta(
|
||||||
4076923.08,
|
4076923.08,
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\tests\Socket\Client;
|
namespace phpOMS\tests\Socket\Client;
|
||||||
|
|
||||||
use phpOMS\Socket\Client\NullClientConnection;
|
|
||||||
use phpOMS\Socket\Client\ClientConnection;
|
use phpOMS\Socket\Client\ClientConnection;
|
||||||
|
use phpOMS\Socket\Client\NullClientConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ class GraphTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->graph->getEdge($node1->getId(), $node3->getId())->getNode2()->getId()
|
$this->graph->getEdge($node1->getId(), $node3->getId())->getNode2()->getId()
|
||||||
);
|
);
|
||||||
|
|
||||||
self::assertEquals(null, $this->graph->getEdge('invalid1', 'invalid2'));
|
self::assertNull($this->graph->getEdge('invalid1', 'invalid2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\tests\Stdlib\Graph;
|
namespace phpOMS\tests\Stdlib\Graph;
|
||||||
|
|
||||||
use phpOMS\Stdlib\Graph\Node;
|
|
||||||
use phpOMS\Stdlib\Graph\Edge;
|
use phpOMS\Stdlib\Graph\Edge;
|
||||||
|
use phpOMS\Stdlib\Graph\Node;
|
||||||
use function PHPUnit\Framework\assertInstanceOf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testdox phpOMS\tests\Stdlib\Graph\NodeTest: Node in a graph
|
* @testdox phpOMS\tests\Stdlib\Graph\NodeTest: Node in a graph
|
||||||
|
|
@ -121,7 +119,7 @@ class NodeTest extends \PHPUnit\Framework\TestCase
|
||||||
$node = new Node('A', 1);
|
$node = new Node('A', 1);
|
||||||
$node->setEdge(new Edge($node, new Node('B')), 3);
|
$node->setEdge(new Edge($node, new Node('B')), 3);
|
||||||
|
|
||||||
self::assertEquals(null, $node->getEdge(2));
|
self::assertNull($node->getEdge(2));
|
||||||
self::assertInstanceOf(Edge::class, $node->getEdge(3));
|
self::assertInstanceOf(Edge::class, $node->getEdge(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user