|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace GraphAware\Neo4jBundle\Collector; |
| 4 | + |
| 5 | +use Symfony\Component\HttpFoundation\Request; |
| 6 | +use Symfony\Component\HttpFoundation\Response; |
| 7 | +use Symfony\Component\HttpKernel\DataCollector\DataCollector; |
| 8 | + |
| 9 | +/** |
| 10 | + * A data collector for the debug plugin. |
| 11 | + * |
| 12 | + * @author Tobias Nyholm <[email protected]> |
| 13 | + */ |
| 14 | +final class Neo4jDataCollector extends DataCollector |
| 15 | +{ |
| 16 | + private $logger; |
| 17 | + |
| 18 | + public function __construct(DebugLogger $logger) |
| 19 | + { |
| 20 | + $this->logger = $logger; |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * {@inheritdoc} |
| 25 | + */ |
| 26 | + public function collect(Request $request, Response $response, \Exception $exception = null) |
| 27 | + { |
| 28 | + } |
| 29 | + |
| 30 | + /** |
| 31 | + * @return array|\GraphAware\Common\Cypher\StatementInterface[] |
| 32 | + */ |
| 33 | + public function getStatements() |
| 34 | + { |
| 35 | + return $this->logger->getStatements(); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @return array|\GraphAware\Common\Result\Result[] |
| 40 | + */ |
| 41 | + public function getResults() |
| 42 | + { |
| 43 | + return $this->logger->getResults(); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @return array|\GraphAware\Neo4j\Client\Exception\Neo4jExceptionInterface[] |
| 48 | + */ |
| 49 | + public function getExceptions() |
| 50 | + { |
| 51 | + return $this->logger->getExceptions(); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * @param int $idx |
| 56 | + * |
| 57 | + * @return bool |
| 58 | + */ |
| 59 | + public function wasSuccessful(int $idx):bool |
| 60 | + { |
| 61 | + return isset($this->logger->getResults()[$idx]); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @return string |
| 66 | + */ |
| 67 | + public function getName() |
| 68 | + { |
| 69 | + return 'neo4j'; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * {@inheritdoc} |
| 74 | + */ |
| 75 | + public function serialize() |
| 76 | + { |
| 77 | + return serialize($this->logger); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * {@inheritdoc} |
| 82 | + */ |
| 83 | + public function unserialize($data) |
| 84 | + { |
| 85 | + $this->logger = unserialize($data); |
| 86 | + } |
| 87 | +} |
0 commit comments