src/Classes/ClassUtil.php
public function callInaccessibleMethod($entity, string $method)
    {
        $rc = new \ReflectionClass($entity);

        if ($rc->hasMethod($method)) {
            $method = $rc->getMethod($method);
            $method->setAccessible(true);

            return $method->invoke($entity);
        }

        return null;
    }
public function callInaccessibleMethod($entity, string $method)
    {
        $rc = new \ReflectionClass($entity);

        if ($rc->hasMethod($method)) {
            $method = $rc->getMethod($method);
            $method->setAccessible(true);

            return $method->invoke($entity);
        }

        return null;
    }
public function callInaccessibleMethod ( $ entity , string $ method ) { $ rc = new \ ReflectionClass ( $ entity ) ; if ( $ rc -> hasMethod ( $ method ) ) { $ method = $ rc -> getMethod ( $ method ) ; $ method -> setAccessible ( true ) ; return $ method -> invoke ( $ entity ) ; } return null ; }
Calls an object's method which is inaccessible.

@param $entity
@param string $method

@throws \ReflectionException

@return mixed|null
Calls an object s method which is inaccessible .