Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
75.00% covered (warning)
75.00%
3 / 4
CRAP
77.78% covered (warning)
77.78%
14 / 18
PostEncrypted
0.00% covered (danger)
0.00%
0 / 1
75.00% covered (warning)
75.00%
3 / 4
9.89
77.78% covered (warning)
77.78%
14 / 18
 __construct($encrypter, $getPasswordCallback = NULL)
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 setGetPasswordCallback($getPasswordCallback, $getPasswordcallbackArgs = array())
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
6 / 6
 setGetPasswordCallbackArgs($getPasswordcallbackArgs = array())
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 offsetGet($offset)
0.00% covered (danger)
0.00%
0 / 1
8.74
33.33% covered (danger)
33.33%
2 / 6
<?php
/**
 *
 */
namespace aae\dispatch\receiver {
    /**
     * @author Axel Ancona Esselmann
     * @package aae\dispatch\receiver
     */
    class PostEncrypted  extends Post {
        private $_encrypter, $_getPasswordCallback = NULL, $_getPasswordcallbackArgs;
        public function __construct($encrypter, $getPasswordCallback = NULL) {
            parent::__construct();
            $this->_encrypter = $encrypter;
            if (!is_null($getPasswordCallback)) $this->setGetPasswordCallback($getPasswordCallback);
        }
        public function setGetPasswordCallback($getPasswordCallback, $getPasswordcallbackArgs = array()) {
            $this->_getPasswordCallback = $getPasswordCallback;
            if (!is_array($getPasswordcallbackArgs)) {
                $getPasswordcallbackArgs = array($getPasswordcallbackArgs);
            }
            $this->setGetPasswordCallbackArgs($getPasswordcallbackArgs);
        }
        public function setGetPasswordCallbackArgs($getPasswordcallbackArgs = array()) {
            $this->_getPasswordcallbackArgs = $getPasswordcallbackArgs;
        }
        public function offsetGet($offset) {
            if (!$this->_encrypter->passwordSet()) {
                if (is_null($this->_getPasswordCallback)) throw new \Exception("No password set for ".get_class($this->_encrypter)." and no callback provided.", 1017141520);
                $password = call_user_func_array($this->_getPasswordCallback, $this->_getPasswordcallbackArgs);
                $this->_encrypter->setPassword($password);
            }
            return isset($this->_container[$offset]) ? $this->_encrypter->decrypt($this->_container[$offset]) : null;
        }
    }
}