class CachedDoubler in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/CachedDoubler.php \Prophecy\Doubler\CachedDoubler
Cached class doubler. Prevents mirroring/creation of the same structure twice.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Prophecy\Doubler\Doubler
- class \Prophecy\Doubler\CachedDoubler
Expanded class hierarchy of CachedDoubler
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ CachedDoubler.php, line 22
Namespace
Prophecy\DoublerView source
class CachedDoubler extends Doubler {
private $classes = array();
/**
* {@inheritdoc}
*/
public function registerClassPatch(ClassPatch\ClassPatchInterface $patch) {
$this->classes[] = array();
parent::registerClassPatch($patch);
}
/**
* {@inheritdoc}
*/
protected function createDoubleClass(ReflectionClass $class = null, array $interfaces) {
$classId = $this
->generateClassId($class, $interfaces);
if (isset($this->classes[$classId])) {
return $this->classes[$classId];
}
return $this->classes[$classId] = parent::createDoubleClass($class, $interfaces);
}
/**
* @param ReflectionClass $class
* @param ReflectionClass[] $interfaces
*
* @return string
*/
private function generateClassId(ReflectionClass $class = null, array $interfaces) {
$parts = array();
if (null !== $class) {
$parts[] = $class
->getName();
}
foreach ($interfaces as $interface) {
$parts[] = $interface
->getName();
}
sort($parts);
return md5(implode('', $parts));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CachedDoubler:: |
private | property | ||
CachedDoubler:: |
protected | function |
Creates double class and returns its FQN. Overrides Doubler:: |
|
CachedDoubler:: |
private | function | ||
CachedDoubler:: |
public | function |
Registers new class patch. Overrides Doubler:: |
|
Doubler:: |
private | property | ||
Doubler:: |
private | property | ||
Doubler:: |
private | property | ||
Doubler:: |
private | property | ||
Doubler:: |
private | property | ||
Doubler:: |
public | function | Creates double from specific class or/and list of interfaces. | |
Doubler:: |
public | function | Returns list of registered class patches. | |
Doubler:: |
public | function | Initializes doubler. |