mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-13 02:21:50 +01:00
Base class for one item - add class constructor & allow to set values directly in the constructor
This commit is contained in:
35
src/Exception/IncorrectClassOfResultItemException.php
Normal file
35
src/Exception/IncorrectClassOfResultItemException.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\LimeSurvey\ApiClient\Base\Result\BaseItem;
|
||||
|
||||
/**
|
||||
* An exception used while class used to create instance of one item of the result, with data fetched from the
|
||||
* LimeSurvey's API, is incorrect
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class IncorrectClassOfResultItemException extends \Exception
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param string $className Incorrect class name used to create instance of one item
|
||||
*/
|
||||
public function __construct($className)
|
||||
{
|
||||
$template = 'Class %s used to create instance of one item of the result should extend %s, but it does not. Did'
|
||||
. ' you forget to use proper base class?';
|
||||
|
||||
$message = sprintf($template, $className, BaseItem::class);
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,8 @@ 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
|
||||
* An exception used while class name used to create instance of one item of the result, with data fetched from the
|
||||
* LimeSurvey's API, is unknown
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
@@ -27,10 +28,10 @@ class UnknownInstanceOfResultItem extends Exception
|
||||
*/
|
||||
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?';
|
||||
$template = 'Class name used to create 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');
|
||||
$message = sprintf($template, $method, ResultProcessor::class, 'getItemClassName');
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user