ConjunctionInterceptor.php in Drupal 7
File
misc/typo3/phar-stream-wrapper/src/Interceptor/ConjunctionInterceptor.php
View source
<?php
namespace TYPO3\PharStreamWrapper\Interceptor;
use TYPO3\PharStreamWrapper\Assertable;
use TYPO3\PharStreamWrapper\Exception;
class ConjunctionInterceptor implements Assertable {
private $assertions;
public function __construct(array $assertions) {
$this
->assertAssertions($assertions);
$this->assertions = $assertions;
}
public function assert($path, $command) {
if ($this
->invokeAssertions($path, $command)) {
return true;
}
throw new Exception(sprintf('Assertion failed in "%s"', $path), 1539625084);
}
private function assertAssertions(array $assertions) {
foreach ($assertions as $assertion) {
if (!$assertion instanceof Assertable) {
throw new \InvalidArgumentException(sprintf('Instance %s must implement Assertable', get_class($assertion)), 1539624719);
}
}
}
private function invokeAssertions($path, $command) {
try {
foreach ($this->assertions as $assertion) {
if (!$assertion
->assert($path, $command)) {
return false;
}
}
} catch (Exception $exception) {
return false;
}
return true;
}
}