Skip to content

Commit

Permalink
Merge pull request #250 from cakephp/fix-exception-messages
Browse files Browse the repository at this point in the history
Fix up exception messages.
  • Loading branch information
dereuromark authored Jan 5, 2024
2 parents 2d49f0b + 76445ad commit 1cca24b
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/Validation/AtValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/AuValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/BdValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/BeValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -65,6 +65,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/CaValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -65,6 +65,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/ChValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -67,6 +67,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/CzValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/DeValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ public static function dob(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/FiValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/GbValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -64,6 +64,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/HrValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -65,6 +65,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/IdValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function mobile(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -79,6 +79,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/InValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/ItValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ public static function cf(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/JpValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ public static function zenkaku(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/LvValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LvValidation extends LocalizedValidation
*/
public static function postal(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/MxValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public static function postal(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/PtValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/RoValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/RsValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ public static function jmbg(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
4 changes: 2 additions & 2 deletions src/Validation/SkValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function postal(string $check): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand All @@ -66,6 +66,6 @@ public static function phone(string $check): bool
*/
public static function personId(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}
}
2 changes: 1 addition & 1 deletion src/Validation/TrValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static function personId(string $tckn): bool
*/
public static function phone(string $check): bool
{
throw new NotImplementedException(__d('localized', '%s Not implemented yet.'));
throw new NotImplementedException(__d('localized', '`{0}()` Not implemented yet.', __METHOD__));
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Validation/TrValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
namespace Cake\Localized\Test\TestCase\Validation;

use Cake\Http\Exception\NotImplementedException;
use Cake\Localized\Validation\TrValidation;
use Cake\TestSuite\TestCase;

Expand Down Expand Up @@ -56,4 +57,15 @@ public function testPersonId()
$this->assertFalse(TrValidation::personId('01216166930'));
$this->assertFalse(TrValidation::personId('31216166931'));
}

/**
* @return void
*/
public function testPhone(): void
{
$this->expectException(NotImplementedException::class);
$this->expectExceptionMessage('`Cake\Localized\Validation\TrValidation::phone()` Not implemented yet.');

TrValidation::phone('');
}
}

0 comments on commit 1cca24b

Please sign in to comment.