public static function checkImmutability($object, array $array)
    {
        $exception = new UnauthorizedModificationException($object);
        foreach ($array as $key => $previousValue) {
            $methodName = 'get'.ucfirst($key);
            if ($previousValue != $object->$methodName()) {
                $exception->addModifiedProperty($key);
            }
        }

        if ($exception->hasModifiedProperty()) {
            throw $exception;
        }
    }
public static function checkImmutability($object, array $array)
    {
        $exception = new UnauthorizedModificationException($object);
        foreach ($array as $key => $previousValue) {
            $methodName = 'get'.ucfirst($key);
            if ($previousValue != $object->$methodName()) {
                $exception->addModifiedProperty($key);
            }
        }

        if ($exception->hasModifiedProperty()) {
            throw $exception;
        }
    }
public static function checkImmutability ( $ object , array $ array ) { $ exception = new UnauthorizedModificationException ( $ object ) ; foreach ( $ array as $ key => $ previousValue ) { $ methodName = 'get' . ucfirst ( $ key ) ; if ( $ previousValue != $ object -> $ methodName ( ) ) { $ exception -> addModifiedProperty ( $ key ) ; } } if ( $ exception -> hasModifiedProperty ( ) ) { throw $ exception ; } }
Check an object data against old values.

@param $object
@param array $array

@throws UnauthorizedModificationException
Check an object data against old values .