Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 669 Bytes

README.md

File metadata and controls

38 lines (29 loc) · 669 Bytes

MySQL Unique Message

A simple library for formatting the duplicate message in MySQL

  • PHP >= 7

Tests

$ composer test

PSR-2

$ composer cs
$ composer csfix

How to use

<?php

use \MySQLUniqueMessage\UniqueMessage;

// This message will return in your mysql using try / catch block
$message = 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry \'[email protected]\' for key \'email\'';
$output = UniqueMessage::format($message); 

Dump from $output

[
	'name' => 'email',
	'value' => '[email protected]',
	'message' => 'The email \'[email protected]\' is already registered.'
];

Enjoy!