3v4l.org

run code in 500+ PHP versions simultaneously
<?php $email = Email::create('TEST@fluentbe.com'); var_dump($email); readonly class Email { final protected function __construct( private string $value, ) { } public static function create(string $value): static { $data = static::recreate($value); $data->guard(); return $data; } public static function recreate(string $value): static { return new static($value); } public function getValue(): string { return $this->value; } public function equals(self $other): bool { return $this->getValue() === $other->getValue(); } protected function guard(): void { if (preg_match("/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_'+\-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/", $this->getValue()) !== 1) { throw new \InvalidArgumentException($this->getValue()); } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  (null)
number of ops:  8
compiled vars:  !0 = $email
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_STATIC_METHOD_CALL                                      'Email', 'create'
          1        SEND_VAL_EX                                                  'TEST%40fluentbe.com'
          2        DO_FCALL                                          0  $1      
          3        ASSIGN                                                       !0, $1
    5     4        INIT_FCALL                                                   'var_dump'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                                     
   43     7      > RETURN                                                       1

Class Email:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        ASSIGN_OBJ                                                   'value'
          2        OP_DATA                                                      !0
   12     3      > RETURN                                                       null

End of function __construct

Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  create
number of ops:  11
compiled vars:  !0 = $value, !1 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   16     1        INIT_STATIC_METHOD_CALL                                      'recreate'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $2      
          4        ASSIGN                                                       !1, $2
   17     5        INIT_METHOD_CALL                                             !1, 'guard'
          6        DO_FCALL                                          0          
   19     7        VERIFY_RETURN_TYPE                                           !1
          8      > RETURN                                                       !1
   20     9*       VERIFY_RETURN_TYPE                                           
         10*     > RETURN                                                       null

End of function create

Function recreate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  recreate
number of ops:  8
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   24     1        NEW                              static              $1      
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
          4        VERIFY_RETURN_TYPE                                           $1
          5      > RETURN                                                       $1
   25     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function recreate

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  getValue
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   FETCH_OBJ_R                                          ~0      'value'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   30     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN                                                       null

End of function getvalue

Function equals:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  equals
number of ops:  10
compiled vars:  !0 = $other
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   RECV                                                 !0      
   34     1        INIT_METHOD_CALL                                             'getValue'
          2        DO_FCALL                                          0  $1      
          3        INIT_METHOD_CALL                                             !0, 'getValue'
          4        DO_FCALL                                          0  $2      
          5        IS_IDENTICAL                                         ~3      $1, $2
          6        VERIFY_RETURN_TYPE                                           ~3
          7      > RETURN                                                       ~3
   35     8*       VERIFY_RETURN_TYPE                                           
          9*     > RETURN                                                       null

End of function equals

Function guard:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n2val
function name:  guard
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   INIT_METHOD_CALL                                             'getValue'
          1        DO_FCALL                                          0  $0      
          2        FRAMELESS_ICALL_2                preg_match          ~1      '%2F%5E%28%3F%21%5C.%29%28%3F%21.%2A%5C.%5C.%29%28%5Ba-zA-Z0-9_%27%2B%5C-.%5D%2A%29%5Ba-zA-Z0-9_%27%2B%5C-%5D%40%28%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9%5C-%5D%2A%5C.%29%2B%5Ba-zA-Z%5D%7B2%2C%7D%24%2F', $0
          3        IS_NOT_IDENTICAL                                             ~1, 1
          4      > JMPZ                                                         ~2, ->11
   40     5    >   NEW                                                  $3      'InvalidArgumentException'
          6        INIT_METHOD_CALL                                             'getValue'
          7        DO_FCALL                                          0  $4      
          8        SEND_VAR_NO_REF_EX                                           $4
          9        DO_FCALL                                          0          
         10      > THROW                                             0          $3
   42    11    > > RETURN                                                       null

End of function guard

End of class Email.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.67 ms | 1336 KiB | 14 Q