|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace steevanb\ContainerIntrospection\Bridge\ContainerIntrospectionBundle\DataCollector; |
| 6 | + |
| 7 | +use steevanb\ContainerIntrospection\ContainerIntrospectionService; |
| 8 | +use Symfony\Component\HttpFoundation\{ |
| 9 | + Request, |
| 10 | + Response |
| 11 | +}; |
| 12 | +use Symfony\Component\HttpKernel\DataCollector\DataCollector; |
| 13 | + |
| 14 | +class ContainerIntrospectionCollector extends DataCollector |
| 15 | +{ |
| 16 | + /** @var ContainerIntrospectionService */ |
| 17 | + protected $introspection; |
| 18 | + |
| 19 | + public function __construct(ContainerIntrospectionService $introspection) |
| 20 | + { |
| 21 | + $this->introspection = $introspection; |
| 22 | + } |
| 23 | + |
| 24 | + public function getName(): string |
| 25 | + { |
| 26 | + return 'steevanb.container_collector'; |
| 27 | + } |
| 28 | + |
| 29 | + public function collect(Request $request, Response $response, \Exception $exception = null): void |
| 30 | + { |
| 31 | + $this->data = [ |
| 32 | + 'containerCachePath' => $this->introspection->getContainerCachePath(), |
| 33 | + 'containerCacheDir' => $this->introspection->getContainerCacheDir(), |
| 34 | + 'countContainerCacheFiles' => $this->introspection->countContainerCacheFiles(), |
| 35 | + 'countContainerCacheLines' => $this->introspection->countContainerCacheLines(), |
| 36 | + 'containerCacheSize' => $this->introspection->getContainerCacheSize(), |
| 37 | + |
| 38 | + 'registeredServices' => $this->introspection->getRegisteredServices(), |
| 39 | + 'countRegisteredServices' => $this->introspection->countRegisteredServices(), |
| 40 | + |
| 41 | + 'instantiatedServices' => $this->introspection->getInstantiatedServices(), |
| 42 | + 'countInstanciatedServices' => $this->introspection->countInstantiatedServices(), |
| 43 | + |
| 44 | + 'publicServices' => $this->introspection->getPublicServices(), |
| 45 | + 'countPublicServices' => $this->introspection->countPublicServices(), |
| 46 | + |
| 47 | + 'privateServices' => $this->introspection->getPrivateServices(), |
| 48 | + 'countPrivateServices' => $this->introspection->countPrivateServices(), |
| 49 | + |
| 50 | + 'parameters' => $this->introspection->getParameters(), |
| 51 | + 'countParameters' => $this->introspection->countParameters() |
| 52 | + ]; |
| 53 | + } |
| 54 | + |
| 55 | + public function reset(): void |
| 56 | + { |
| 57 | + $this->data = []; |
| 58 | + } |
| 59 | + |
| 60 | + public function getContainerCachePath(): string |
| 61 | + { |
| 62 | + return $this->data['containerCachePath']; |
| 63 | + } |
| 64 | + |
| 65 | + public function getContainerCacheDir(): string |
| 66 | + { |
| 67 | + return $this->data['containerCacheDir']; |
| 68 | + } |
| 69 | + |
| 70 | + public function countContainerCacheFiles(): int |
| 71 | + { |
| 72 | + return $this->data['countContainerCacheFiles']; |
| 73 | + } |
| 74 | + |
| 75 | + public function countContainerCacheLines(): int |
| 76 | + { |
| 77 | + return $this->data['countContainerCacheLines']; |
| 78 | + } |
| 79 | + |
| 80 | + public function getContainerCacheSize(): int |
| 81 | + { |
| 82 | + return $this->data['containerCacheSize']; |
| 83 | + } |
| 84 | + |
| 85 | + public function getRegisteredServices(): array |
| 86 | + { |
| 87 | + return $this->data['registeredServices']; |
| 88 | + } |
| 89 | + |
| 90 | + public function countRegisteredServices(): int |
| 91 | + { |
| 92 | + return $this->data['countRegisteredServices']; |
| 93 | + } |
| 94 | + |
| 95 | + public function getInstantiatedServices(): array |
| 96 | + { |
| 97 | + return $this->data['instantiatedServices']; |
| 98 | + } |
| 99 | + |
| 100 | + public function countInstantiatedServices(): int |
| 101 | + { |
| 102 | + return $this->data['countInstanciatedServices']; |
| 103 | + } |
| 104 | + |
| 105 | + public function getPublicServices(): array |
| 106 | + { |
| 107 | + return $this->data['publicServices']; |
| 108 | + } |
| 109 | + |
| 110 | + public function countPublicServices(): int |
| 111 | + { |
| 112 | + return $this->data['countPublicServices']; |
| 113 | + } |
| 114 | + |
| 115 | + public function getPrivateServices(): array |
| 116 | + { |
| 117 | + return $this->data['privateServices']; |
| 118 | + } |
| 119 | + |
| 120 | + public function countPrivateServices(): int |
| 121 | + { |
| 122 | + return $this->data['countPrivateServices']; |
| 123 | + } |
| 124 | + |
| 125 | + public function getParameters(): array |
| 126 | + { |
| 127 | + return $this->data['parameters']; |
| 128 | + } |
| 129 | + |
| 130 | + public function countParameters(): int |
| 131 | + { |
| 132 | + return $this->data['countParameters']; |
| 133 | + } |
| 134 | +} |
0 commit comments