Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
invalidAccessKey example
public
static
function
generateSecretAccessKey
(
)
: string
{
return
str_replace
(
[
'+', '/', '='
]
,
[
'-', '_', ''
]
,
base64_encode
(
Random::
getAlphanumericString
(
38
)
)
)
;
}
public
static
function
getOrigin
(
string
$accessKey
)
: string
{
$identifier
=
mb_substr
(
$accessKey
, 0, 4
)
;
if
(
!
isset
(
self::
$mapping
[
$identifier
]
)
)
{
throw
ApiException::
invalidAccessKey
(
)
;
}
return
self::
$mapping
[
$identifier
]
;
}
private
static
function
getIdentifier
(
string
$origin
)
: string
{
$mapping
=
array_flip
(
self::
$mapping
)
;
if
(
!
isset
(
$mapping
[
$origin
]
)
)
{
throw
ApiException::
invalidAccessKeyIdentifier
(
)
;
}
public
function
testInvalidSchemaDefinitions
(
)
: void
{
$exception
= ApiException::
invalidSchemaDefinitions
(
'file',
new
\
JsonException
(
)
)
;
static
::
assertEquals
(
ApiException::API_INVALID_SCHEMA_DEFINITION_EXCEPTION,
$exception
->
getErrorCode
(
)
)
;
}
public
function
testInvalidAccessKey
(
)
: void
{
$exception
= ApiException::
invalidAccessKey
(
)
;
static
::
assertEquals
(
ApiException::API_INVALID_ACCESS_KEY_EXCEPTION,
$exception
->
getErrorCode
(
)
)
;
}
public
function
testInvalidAccessKeyIdentifier
(
)
: void
{
$exception
= ApiException::
invalidAccessKeyIdentifier
(
)
;
static
::
assertEquals
(
ApiException::API_INVALID_ACCESS_KEY_IDENTIFIER_EXCEPTION,
$exception
->
getErrorCode
(
)
)
;
}