Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this encapsulation?

I read many times about encapsulation, but always I see a code like this I finish wondering the same. Is it this encapsulation?

class create_active_parent{



function __construct(){
     //something
}


function clean_queues_redis(){
    //creating in this way an object, and using it, is not encapsulation, is it?
    $redis = RedisDB::fetch_instance();        
    $redis->db->flushdb();  
}
like image 706
itaka Avatar asked May 02 '26 04:05

itaka


1 Answers

Encapsulation is to hide private fields from outside. $redis is just a local variable, and it will die at the end of clean_queues_redis method execution.

like image 91
moonwave99 Avatar answered May 04 '26 18:05

moonwave99



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!