for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Thruster\Component\MysqlClient\Exception;
/**
* Class RecordDuplicateException
*
* @package Thruster\Component\MysqlClient\Exception
* @author Aurimas Niekis <[email protected]>
*/
class RecordDuplicateException extends QueryException
{
* @var string
private $field;
private $value;
public function __construct(string $message)
preg_match('/Duplicate entry \'([^\']+)\' for key \'([^\']+)\'/', $message, $matches);
$this->value = $matches[1] ?? '';
$this->field = $matches[2] ?? '';
parent::__construct($message, 1062);
}
* @return string
public function getField()
return $this->field;
public function getValue()
return $this->value;