mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-13 02:21:50 +01:00
composer.json - move tests-related classes to "autoload-dev" section (used for development purposes only and avoid polluting the autoloader in production)
This commit is contained in:
31
src/Exception/CannotProcessDataException.php
Normal file
31
src/Exception/CannotProcessDataException.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Exception;
|
||||
|
||||
/**
|
||||
* An exception used while raw data returned by the LimeSurvey's API cannot be processed
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class CannotProcessDataException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $reason Reason why data cannot be processed, e.g. "Invalid user name or password"
|
||||
*/
|
||||
public function __construct($reason)
|
||||
{
|
||||
$template = 'Raw data returned by the LimeSurvey\'s API cannot be processed. Reason: \'%s\'.';
|
||||
$message = sprintf($template, $reason);
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
36
src/Exception/CreateSessionKeyFailedException.php
Normal file
36
src/Exception/CreateSessionKeyFailedException.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* An exception used while create of the session key has failed
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class CreateSessionKeyFailedException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $reason (optional) Reason of failure, e.g. "Invalid user name or password"
|
||||
*/
|
||||
public function __construct($reason = '')
|
||||
{
|
||||
$message = 'Create of the session key has failed';
|
||||
|
||||
if (!empty($reason)) {
|
||||
$message = sprintf('%s. Reason: \'%s\'.', $message, $reason);
|
||||
}
|
||||
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
45
src/Exception/InvalidResultOfMethodRunException.php
Normal file
45
src/Exception/InvalidResultOfMethodRunException.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Exception;
|
||||
|
||||
use Exception;
|
||||
use Meritoo\Common\Utilities\Arrays;
|
||||
|
||||
/**
|
||||
* An exception used when an error occurred while running method
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class InvalidResultOfMethodRunException extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param Exception $previousException The previous exception, source of an error
|
||||
* @param string $methodName Name of called method
|
||||
* @param array $methodArguments (optional) Arguments of the called method
|
||||
*/
|
||||
public function __construct(Exception $previousException, $methodName, array $methodArguments = [])
|
||||
{
|
||||
$template = "Oops, an error occurred while running method. Is there everything ok? Details:\n"
|
||||
. "- error: %s,\n"
|
||||
. "- method: %s,\n"
|
||||
. '- arguments: %s.';
|
||||
|
||||
if (empty($methodArguments)) {
|
||||
$methodArguments = '(no arguments)';
|
||||
} else {
|
||||
$methodArguments = Arrays::valuesKeys2string($methodArguments, ', ', '=', '"');
|
||||
}
|
||||
|
||||
$message = sprintf($template, $previousException->getMessage(), $methodName, $methodArguments);
|
||||
parent::__construct($message, $previousException->getCode());
|
||||
}
|
||||
}
|
||||
36
src/Exception/UnknownInstanceOfResultItem.php
Normal file
36
src/Exception/UnknownInstanceOfResultItem.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Exception;
|
||||
|
||||
use Exception;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Processor\ResultProcessor;
|
||||
|
||||
/**
|
||||
* An exception used while instance of one item used by result, with data fetched from the LimeSurvey's API, is unknown
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class UnknownInstanceOfResultItem extends Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $method Name of called method while talking to the LimeSurvey's API. One of the MethodType class
|
||||
* constants.
|
||||
*/
|
||||
public function __construct($method)
|
||||
{
|
||||
$template = 'Instance of one item used by result the of \'%s\' LimeSurvey API\'s method is unknown. Proper'
|
||||
. ' class is not mapped in %s::%s() method. Did you forget about this?';
|
||||
|
||||
$message = sprintf($template, $method, ResultProcessor::class, 'getItemInstance');
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
29
src/Exception/UnknownMethodException.php
Normal file
29
src/Exception/UnknownMethodException.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\ApiClient\Exception;
|
||||
|
||||
use Meritoo\Common\Exception\Base\UnknownTypeException;
|
||||
use Meritoo\LimeSurvey\ApiClient\Type\MethodType;
|
||||
|
||||
/**
|
||||
* An exception used while name of method used while talking to the LimeSurvey's API is unknown
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class UnknownMethodException extends UnknownTypeException
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($unknownType)
|
||||
{
|
||||
parent::__construct($unknownType, new MethodType(), 'name of method used while talking to the LimeSurvey\'s API');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user