File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 1+ <?php 
2+ 
3+ namespace  JustSteveKing \Laravel \FeatureFlags \Exceptions ;
4+ 
5+ use  Exception ;
6+ 
7+ class  ExpiredFeatureException extends  Exception
8+ {
9+     public  static  function  create (string  $ feature
10+     {
11+         return  new  static ("The Feature  {$ feature has expired. " );
12+     }
13+ }
Original file line number Diff line number Diff line change 55namespace  JustSteveKing \Laravel \FeatureFlags \Models ;
66
77use  Carbon \Carbon ;
8- use  Exception ;
98use  Illuminate \Database \Eloquent \Model ;
109use  Illuminate \Database \Eloquent \Relations \BelongsToMany ;
1110use  Illuminate \Support \Facades \App ;
12- use  JustSteveKing \Laravel \FeatureFlags \Models \ Concerns \ NormaliseName ;
11+ use  JustSteveKing \Laravel \FeatureFlags \Exceptions \ ExpiredFeatureException ;
1312use  JustSteveKing \Laravel \FeatureFlags \Models \Builders \FeatureBuilder ;
13+ use  JustSteveKing \Laravel \FeatureFlags \Models \Concerns \NormaliseName ;
1414
1515class  Feature extends  Model
1616{
@@ -30,15 +30,15 @@ class Feature extends Model
3030
3131    public  static  function  booted (): void 
3232    {
33-         static ::retrieved (function (Feature $ feature
33+         static ::retrieved (function   (Feature $ feature
3434            $ timeBombsAreEnabledconfig ('feature-flags.enable_time_bombs ' );
35-             $ environmentAllowsTimeBombs  App::environment (config ('feature-flags.time_bomb_environments ' ));
35+             $ environmentAllowsTimeBombsenvironment (config ('feature-flags.time_bomb_environments ' ));
3636
37-             if ($ timeBombsAreEnabled$ environmentAllowsTimeBombs
37+             if   ($ timeBombsAreEnabled$ environmentAllowsTimeBombs
3838                $ featureHasExpirednow ()->isAfter ($ featureexpires_at );
3939
4040                if  ($ featureHasExpired
41-                     throw  new   Exception ( sprintf ( ' The Feature has expired - %s ' ,  $ featurename ) );
41+                     throw  ExpiredFeatureException:: create ( $ featurename );
4242                }
4343                return  true ;
4444            }
Original file line number Diff line number Diff line change 33declare (strict_types=1 );
44
55use  Carbon \Carbon ;
6+ use  JustSteveKing \Laravel \FeatureFlags \Exceptions \ExpiredFeatureException ;
67use  JustSteveKing \Laravel \FeatureFlags \Models \Feature ;
78use  Illuminate \Support \Facades \Config ;
89
@@ -54,7 +55,7 @@ function tryException() {
5455    ]);
5556
5657    Feature::all ();
57- })->throws (Exception ::class, 'The Feature has  expired - expired feature  ' );
58+ })->throws (ExpiredFeatureException ::class, 'The Feature expired feature has expired.  ' );
5859
5960it ('casts the Expiry date to Carbon ' , function (): void  {
6061   Feature::create ([
@@ -72,7 +73,7 @@ function tryException() {
7273    ]);
7374
7475    Feature::all ();
75- })->throws (Exception ::class, 'The Feature has  expired - expired feature  ' );
76+ })->throws (ExpiredFeatureException ::class, 'The Feature expired feature has expired.  ' );
7677
7778it ('Does not throw an Exception when an expiry date is 1 second in the future ' , function (): void  {
7879    Feature::create ([
@@ -101,4 +102,4 @@ function tryException() {
101102    ]);
102103
103104    Feature::all ();
104- })->throws (Exception ::class, 'The Feature has  expired - expired feature  ' );
105+ })->throws (ExpiredFeatureException ::class, 'The Feature expired feature has expired.  ' );
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments