@@ -21,16 +21,13 @@ public static function className( ?string $className ): string
2121 * Check if the model exists, otherwise throw an error.
2222 *
2323 * @param object|null $model
24- * @param int $id
25- * @param string|null $modelClass
24+ * @param int|string|null $id
2625 * @return bool
2726 * @throws ErrorException
2827 */
29- public static function isModelExists ( ?object $ model = null , ? int $ id , ?string $ modelClass = 'Model ' ): bool
28+ public static function isModelExists ( ?object $ model = null , int | string | null $ id , ?string $ modelName = 'Object ' ): bool
3029 {
31- if ( empty ( $ model ) ) {
32- $ modelName = class_basename ( $ modelClass );
33-
30+ if ( empty ( $ model ) ) {
3431 self ::throwError (
3532 errorMsg : __ ('GL_NotExist ' ) . " {$ modelName }: {$ id }" ,
3633 action : 'isModelExists ' ,
@@ -45,34 +42,30 @@ public static function isModelExists( ?object $model = null, ?int $id, ?string $
4542 *
4643 * @param mixed $record
4744 * @param int|string|null $id
48- * @param string|null $className
49- * @return bool Returns true if the record is empty, otherwise throws an error.
50- * @throws ErrorException If the record is not empty.
45+ * @return bool
46+ * @throws ErrorException
5147 */
52- public static function isRecordEmpty ( mixed $ record = null , int |string |null $ id, ? string $ className = null ): bool
48+ public static function isRecordEmpty ( mixed $ record = null , int |string |null $ id ): bool
5349 {
54- if ( !empty ( $ record ) ) {
50+ if ( !empty ( $ record ) ) {
5551 self ::throwError (
5652 errorMsg : __ ('GL_RecordExist ' ) . ": {$ id }" ,
5753 action : 'isRecordExist ' ,
58- className : self ::className ( $ className ),
5954 );
6055 }
6156
6257 return true ;
6358 }
6459
65-
6660 /**
6761 * Check if two values are equal.
6862 *
6963 * @param int|string $currentValue
7064 * @param int|string $checkValue
71- * @param string|null $className
7265 * @return bool
7366 * @throws ErrorException
7467 */
75- public static function isValuesEqual ( int |string $ currentValue , int |string $ checkValue, ? string $ className = null ): bool
68+ public static function isValuesEqual ( int |string $ currentValue , int |string $ checkValue ): bool
7669 {
7770 if ( $ currentValue === $ checkValue ) {
7871 return true ;
@@ -81,25 +74,22 @@ public static function isValuesEqual( int|string $currentValue, int|string $chec
8174 self ::throwError (
8275 errorMsg : __ ('GL_ValuesNotEqual ' ),
8376 action : 'isValuesEqual ' ,
84- className : self ::className ( $ className ),
8577 );
8678 }
8779
8880 /**
8981 * Check if the validator has failed.
9082 *
9183 * @param Validator $validator
92- * @param string|null $className
9384 * @return void
9485 * @throws ErrorException
9586 */
96- public static function isFails ( Validator $ validator, ? string $ className = null ): void
87+ public static function isFails ( Validator $ validator ): void
9788 {
9889 if ( $ validator ->fails () ) {
9990 self ::throwError (
10091 errorMsg : $ validator ->errors ()->first (),
10192 action : 'validator ' ,
102- className : self ::className ( $ className )
10393 );
10494 }
10595 }
@@ -109,20 +99,18 @@ className : self::className( $className )
10999 *
110100 * @param mixed $value
111101 * @param string|null $errorMsg
112- * @param string|null $className
113102 * @return bool
114103 * @throws ErrorException
115104 */
116- public static function isEmpty ( mixed $ value , ?string $ errorMsg = null , ? string $ className = null ): bool
105+ public static function isEmpty ( mixed $ value , ?string $ errorMsg = null ): bool
117106 {
118- if ( !empty ( $ value ) ){
107+ if ( !empty ( $ value ) ) {
119108 return true ;
120109 }
121110
122111 self ::throwError (
123- errorMsg : $ errorMsg ? $ errorMsg : __ ('GL_NotExist ' ),
124- action : 'isEmpty ' ,
125- className : self ::className ( $ className )
112+ errorMsg : $ errorMsg ?: __ ('GL_NotExist ' ),
113+ action : 'isEmpty '
126114 );
127115 }
128116
@@ -131,17 +119,15 @@ className : self::className( $className )
131119 *
132120 * @param int $user_id
133121 * @param int $author_id
134- * @param string|null $className
135122 * @return bool
136123 * @throws ErrorException
137124 */
138- public static function isAuthor ( int $ user_id , int $ author_id, ? string $ className = null ): bool
125+ public static function isAuthor ( int $ user_id , int $ author_id ): bool
139126 {
140- if ( $ user_id !== $ author_id ) {
127+ if ( $ user_id !== $ author_id ) {
141128 self ::throwError (
142129 errorMsg : __ ('GL_ACTION_FAILED_Rights ' ),
143130 action : 'isAuthor ' ,
144- className : self ::className ( $ className )
145131 );
146132 }
147133
@@ -156,7 +142,7 @@ className : self::className( $className )
156142 */
157143 public static function getErrorValidator ( Validator $ validator ): string
158144 {
159- foreach ( $ validator ->messages ()->getMessages () as $ field_name => $ messages ){
145+ foreach ( $ validator ->messages ()->getMessages () as $ field_name => $ messages ) {
160146 return $ field_name . ': ' . $ messages [0 ];
161147 }
162148 }
0 commit comments