Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Exceptions; |
| 4 | |
| 5 | use LdapRecord\DetectsErrors; |
| 6 | use LdapRecord\LdapRecordException; |
| 7 | |
| 8 | class ConstraintViolationException extends LdapRecordException |
| 9 | { |
| 10 | use DetectsErrors; |
| 11 | |
| 12 | /** |
| 13 | * Determine if the exception was generated due to the password policy. |
| 14 | * |
| 15 | * @return bool |
| 16 | */ |
| 17 | public function causedByPasswordPolicy() |
| 18 | { |
| 19 | return isset($this->detailedError) |
| 20 | ? $this->errorContainsMessage($this->detailedError->getDiagnosticMessage(), '0000052D') |
| 21 | : false; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Determine if the exception was generated due to an incorrect password. |
| 26 | * |
| 27 | * @return bool |
| 28 | */ |
| 29 | public function causedByIncorrectPassword() |
| 30 | { |
| 31 | return isset($this->detailedError) |
| 32 | ? $this->errorContainsMessage($this->detailedError->getDiagnosticMessage(), '00000056') |
| 33 | : false; |
| 34 | } |
| 35 | } |