@@ -376,12 +376,9 @@ public function testRandomBytes(): void
376
376
$ bytes = Utility::randomBytes (8 );
377
377
$ this ->assertNotEmpty ($ bytes );
378
378
379
- try {
380
- $ this ->expectException (\Random \RandomException::class);
381
- $ bytes = Utility::randomBytes (0 );
382
- } finally {
383
- //
384
- }
379
+ $ this ->expectException (\Random \RandomException::class);
380
+ $ bytes = Utility::randomBytes (0 );
381
+
385
382
}
386
383
387
384
/**
@@ -392,15 +389,11 @@ public function testRandomInt(): void
392
389
$ int = Utility::randomInt (100 , 250 );
393
390
$ this ->assertTrue (($ int >= 100 and $ int <= 250 ));
394
391
395
- try {
396
- $ this ->expectException (\Random \RandomException::class);
397
- $ int = Utility::randomInt (intval (\PHP_INT_MIN - 1 ), \PHP_INT_MAX );
398
392
399
- $ this ->expectException (\Random \RandomException::class);
400
- $ int = Utility::randomInt (\PHP_INT_MAX , \PHP_INT_MIN );
401
- } finally {
402
- //
403
- }
393
+ $ this ->expectException (\Random \RandomException::class);
394
+ $ int = Utility::randomInt (\intval (\PHP_INT_MIN - 1 ), \PHP_INT_MAX );
395
+ $ int = Utility::randomInt (\PHP_INT_MAX , \PHP_INT_MIN );
396
+
404
397
}
405
398
406
399
/**
@@ -411,12 +404,9 @@ public function testRandomString(): void
411
404
$ str = Utility::randomString (16 );
412
405
$ this ->assertTrue (Utility::length ($ str ) === 16 );
413
406
414
- try {
415
- $ this ->expectException (\Random \RandomException::class);
416
- $ str = Utility::randomString (-10 );
417
- } finally {
418
- //
419
- }
407
+ $ this ->expectException (\Random \RandomException::class);
408
+ $ str = Utility::randomString (-10 );
409
+
420
410
}
421
411
422
412
/**
@@ -429,12 +419,8 @@ public function testLineCounter(): void
429
419
$ this ->assertEquals (0 , \array_sum (Utility::lineCounter (directory: self ::$ testDir , ignore: ['dir1 ' ], onlyLineCount: true )));
430
420
Utility::fileWrite (self ::$ testFiles ['file1 ' ], '' );
431
421
432
- try {
433
- $ this ->expectException (\InvalidArgumentException::class);
434
- $ count = \array_sum (Utility::lineCounter ('/this/should/not/exist ' , onlyLineCount: true ));
435
- } finally {
436
- //
437
- }
422
+ $ this ->expectException (\InvalidArgumentException::class);
423
+ $ count = \array_sum (Utility::lineCounter ('/this/should/not/exist ' , onlyLineCount: true ));
438
424
}
439
425
440
426
/**
@@ -451,12 +437,8 @@ public function testDirectorySize(): void
451
437
Utility::fileWrite (self ::$ testFiles ['file1 ' ], '' );
452
438
Utility::fileWrite (self ::$ testFiles ['file2 ' ], '' );
453
439
454
- try {
455
- $ this ->expectException (\InvalidArgumentException::class);
456
- $ count = Utility::directorySize ('/this/should/not/exist ' );
457
- } finally {
458
- //
459
- }
440
+ $ this ->expectException (\InvalidArgumentException::class);
441
+ $ count = Utility::directorySize ('/this/should/not/exist ' );
460
442
}
461
443
462
444
/**
@@ -482,12 +464,8 @@ public function testDirectoryList(): void
482
464
Utility::fileWrite (self ::$ testFiles ['file1 ' ], '' );
483
465
Utility::fileWrite (self ::$ testFiles ['file2 ' ], '' );
484
466
485
- try {
486
- $ this ->expectException (\InvalidArgumentException::class);
487
- $ count = Utility::directoryList ('/this/should/not/exist ' );
488
- } finally {
489
- //
490
- }
467
+ $ this ->expectException (\InvalidArgumentException::class);
468
+ $ count = Utility::directoryList ('/this/should/not/exist ' );
491
469
}
492
470
493
471
/**
@@ -520,12 +498,8 @@ public function testFileRead(): void
520
498
521
499
Utility::fileWrite (self ::$ testFiles ['file1 ' ], '' );
522
500
523
- try {
524
- $ this ->expectException (\InvalidArgumentException::class);
525
- $ read = Utility::fileRead (self ::$ testFiles ['file1 ' ] . '.php ' );
526
- } finally {
527
- //
528
- }
501
+ $ this ->expectException (\InvalidArgumentException::class);
502
+ $ read = Utility::fileRead (self ::$ testFiles ['file1 ' ] . '.php ' );
529
503
}
530
504
531
505
/**
@@ -537,12 +511,8 @@ public function testFileWrite(): void
537
511
538
512
Utility::fileWrite (self ::$ testFiles ['file1 ' ], '' );
539
513
540
- try {
541
- $ this ->expectException (\InvalidArgumentException::class);
542
- $ read = Utility::fileWrite (self ::$ testFiles ['file1 ' ] . '.php ' );
543
- } finally {
544
- //
545
- }
514
+ $ this ->expectException (\InvalidArgumentException::class);
515
+ $ read = Utility::fileWrite (self ::$ testFiles ['file1 ' ] . '.php ' );
546
516
}
547
517
548
518
/**
@@ -723,16 +693,9 @@ public function testTimeDifference(): void
723
693
724
694
$ this ->assertEquals ('1 second(s) old ' , Utility::timeDifference (\time () - 1 , 0 , '' ));
725
695
726
- try {
727
- $ this ->expectException (\InvalidArgumentException::class);
728
- $ time = Utility::timeDifference (\time () - 30 , 0 , 'INVALID ' );
729
-
730
- $ this ->expectException (\InvalidArgumentException::class);
731
- $ time = Utility::timeDifference (-8400 , 0 );
732
- } finally {
733
- //
734
- }
735
-
696
+ $ this ->expectException (\InvalidArgumentException::class);
697
+ $ time = Utility::timeDifference (\time () - 30 , 0 , 'INVALID ' );
698
+ $ time = Utility::timeDifference (-8400 , 0 );
736
699
}
737
700
738
701
/**
@@ -803,12 +766,8 @@ public function testObscureEmail(): void
803
766
Utility::
obscureEmail (
'[email protected] ' )
804
767
);
805
768
806
- try {
807
- $ this ->expectException (\InvalidArgumentException::class);
808
- $ email = Utility::obscureEmail ('thisisnotvalid&!-- ' );
809
- } finally {
810
- //
811
- }
769
+ $ this ->expectException (\InvalidArgumentException::class);
770
+ $ email = Utility::obscureEmail ('thisisnotvalid&!-- ' );
812
771
}
813
772
814
773
/**
0 commit comments