3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Scholarship extends Model { protected $table = 'scholarships'; protected $primaryKey = 'scholarship_id'; public $incrementing = false; protected $keyType = 'string'; public $timestamps = false; protected $guarded = []; public function checklists() { return $this->hasMany(GuidanceChecklist::class, 'scholarship_id', 'scholarship_id'); } public function applications() { return $this->hasMany(StudentApplication::class, 'scholarship_id', 'scholarship_id'); } public static function calculateEligibility( Scholarship $scholarship, float $studentCgpa, ?string $studentField ): float { // Step 1: Calculate CGPA Score (70%) if ($scholarship->min_cgpa <= 0) { $cgpaScore = 70; } else { $cgpaScore = min( $studentCgpa / $scholarship->min_cgpa, 1 ) * 70; } // Step 2: Calculate Field of Study Score (30%) $scholarshipField = trim( (string) $scholarship->field_of_study ); $studentField = trim((string) $studentField); if ( $scholarshipField === '' || strtolower($scholarshipField) === 'open' || ( $studentField !== '' && strcasecmp($scholarshipField, $studentField) === 0 ) ) { $fieldScore = 30; } else { $fieldScore = 0; } // Step 3: Calculate Final Score $totalScore = $cgpaScore + $fieldScore; // Step 4: Return score between 0 and 100 return round( max(0, min($totalScore, 100)), 2 ); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mpi74
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                                'app%5Cmodels%5Cscholarship', 'illuminate%5Cdatabase%5Celoquent%5Cmodel'
   73     1      > RETURN                                                       1

Class App\Models\Scholarship:
Function checklists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mpi74
function name:  checklists
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   INIT_METHOD_CALL                                             'hasMany'
          1        SEND_VAL_EX                                                  'App%5CModels%5CGuidanceChecklist'
          2        SEND_VAL_EX                                                  'scholarship_id'
          3        SEND_VAL_EX                                                  'scholarship_id'
          4        DO_FCALL                                          0  $0      
          5      > RETURN                                                       $0
   20     6*     > RETURN                                                       null

End of function checklists

Function applications:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Mpi74
function name:  applications
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   INIT_METHOD_CALL                                             'hasMany'
          1        SEND_VAL_EX                                                  'App%5CModels%5CStudentApplication'
          2        SEND_VAL_EX                                                  'scholarship_id'
          3        SEND_VAL_EX                                                  'scholarship_id'
          4        DO_FCALL                                          0  $0      
          5      > RETURN                                                       $0
   25     6*     > RETURN                                                       null

End of function applications

Function calculateeligibility:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 208) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 208) Position 1 = 33, Position 2 = 38
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 47) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
2 jumps found. (Code = 47) Position 1 = 49, Position 2 = 58
Branch analysis from position: 49
2 jumps found. (Code = 46) Position 1 = 51, Position 2 = 57
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 61
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 208) Position 1 = 66, Position 2 = 75
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 75
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
2 jumps found. (Code = 208) Position 1 = 66, Position 2 = 75
Branch analysis from position: 66
Branch analysis from position: 75
Branch analysis from position: 57
Branch analysis from position: 58
Branch analysis from position: 48
Branch analysis from position: 38
2 jumps found. (Code = 47) Position 1 = 43, Position 2 = 48
Branch analysis from position: 43
Branch analysis from position: 48
Branch analysis from position: 28
2 jumps found. (Code = 208) Position 1 = 33, Position 2 = 38
Branch analysis from position: 33
Branch analysis from position: 38
Branch analysis from position: 8
2 jumps found. (Code = 208) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 208) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
Branch analysis from position: 28
Branch analysis from position: 16
2 jumps found. (Code = 208) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
Branch analysis from position: 28
filename:       /in/Mpi74
function name:  calculateEligibility
number of ops:  87
compiled vars:  !0 = $scholarship, !1 = $studentCgpa, !2 = $studentField, !3 = $cgpaScore, !4 = $scholarshipField, !5 = $fieldScore, !6 = $totalScore
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   RECV                                                 !0      
   29     1        RECV                                                 !1      
   30     2        RECV                                                 !2      
   34     3        FETCH_OBJ_R                                          ~7      !0, 'min_cgpa'
          4        IS_SMALLER_OR_EQUAL                                          ~7, 0
          5      > JMPZ                                                         ~8, ->8
   35     6    >   ASSIGN                                                       !3, 70
   34     7      > JMP                                                          ->21
   37     8    > > JMP_FRAMELESS                                   s80          'app%5Cmodels%5Cmin', ->16
          9    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cmin'
   38    10        FETCH_OBJ_R                                          ~10     !0, 'min_cgpa'
         11        DIV                                                  ~11     !1, ~10
         12        SEND_VAL_EX                                                  ~11
   39    13        SEND_VAL_EX                                                  1
   37    14        DO_FCALL                                          0  $12     
         15      > JMP                                                          ->19
   38    16    >   FETCH_OBJ_R                                          ~13     !0, 'min_cgpa'
         17        DIV                                                  ~14     !1, ~13
   37    18        FRAMELESS_ICALL_2                min                 $12     ~14, 1
   40    19    >   MUL                                                  ~15     $12, 70
   37    20        ASSIGN                                                       !3, ~15
   44    21    > > JMP_FRAMELESS                                   s144         'app%5Cmodels%5Ctrim', ->28
         22    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Ctrim'
   45    23        FETCH_OBJ_R                                          ~17     !0, 'field_of_study'
         24        CAST                                              6  ~18     ~17
         25        SEND_VAL_EX                                                  ~18
   44    26        DO_FCALL                                          0  $19     
         27      > JMP                                                          ->31
   45    28    >   FETCH_OBJ_R                                          ~20     !0, 'field_of_study'
         29        CAST                                              6  ~21     ~20
   44    30        FRAMELESS_ICALL_1                trim                $19     ~21
         31    >   ASSIGN                                                       !4, $19
   48    32      > JMP_FRAMELESS                                   s160         'app%5Cmodels%5Ctrim', ->38
         33    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Ctrim'
         34        CAST                                              6  ~23     !2
         35        SEND_VAL_EX                                                  ~23
         36        DO_FCALL                                          0  $24     
         37      > JMP                                                          ->40
         38    >   CAST                                              6  ~25     !2
         39        FRAMELESS_ICALL_1                trim                $24     ~25
         40    >   ASSIGN                                                       !2, $24
   51    41        IS_IDENTICAL                                         ~27     !4, ''
         42      > JMPNZ_EX                                             ~27     ~27, ->48
   52    43    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cstrtolower'
         44        SEND_VAR_EX                                                  !4
         45        DO_FCALL                                          0  $28     
         46        IS_IDENTICAL                                         ~29     $28, 'open'
         47        BOOL                                                 ~27     ~29
         48    > > JMPNZ_EX                                             ~27     ~27, ->58
   54    49    >   IS_NOT_IDENTICAL                                     ~30     !2, ''
         50      > JMPZ_EX                                              ~30     ~30, ->57
   55    51    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cstrcasecmp'
         52        SEND_VAR_EX                                                  !4
         53        SEND_VAR_EX                                                  !2
         54        DO_FCALL                                          0  $31     
         55        IS_IDENTICAL                                         ~32     $31, 0
         56        BOOL                                                 ~30     ~32
         57    >   BOOL                                                 ~27     ~30
         58    > > JMPZ                                                         ~27, ->61
   58    59    >   ASSIGN                                                       !5, 30
   51    60      > JMP                                                          ->62
   60    61    >   ASSIGN                                                       !5, 0
   64    62    >   ADD                                                  ~35     !3, !5
         63        ASSIGN                                                       !6, ~35
   67    64        INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cround'
   68    65      > JMP_FRAMELESS                                   s216         'app%5Cmodels%5Cmax', ->75
         66    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cmax'
         67        SEND_VAL_EX                                                  0
         68        INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cmin'
         69        SEND_VAR_EX                                                  !6
         70        SEND_VAL_EX                                                  100
         71        DO_FCALL                                          0  $37     
         72        SEND_VAR_NO_REF_EX                                           $37
         73        DO_FCALL                                          0  $38     
         74      > JMP                                                          ->80
         75    >   INIT_NS_FCALL_BY_NAME                                        'App%5CModels%5Cmin'
         76        SEND_VAR_EX                                                  !6
         77        SEND_VAL_EX                                                  100
         78        DO_FCALL                                          0  $39     
         79        FRAMELESS_ICALL_2                max                 $38     0, $39
         80    >   SEND_VAR_NO_REF_EX                                           $38
   69    81        SEND_VAL_EX                                                  2
   67    82        DO_FCALL                                          0  $40     
   69    83        VERIFY_RETURN_TYPE                                           $40
         84      > RETURN                                                       $40
   71    85*       VERIFY_RETURN_TYPE                                           
         86*     > RETURN                                                       null

End of function calculateeligibility

End of class App\Models\Scholarship.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
129.58 ms | 505 KiB | 15 Q