1 | <?php |
||
29 | class RepositoryReportHelper { |
||
30 | |||
31 | use EntityManagerTrait; |
||
32 | |||
33 | /** |
||
34 | * Service name. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | const SERVICE_NAME = "wbw.core.helper.repository_report"; |
||
39 | |||
40 | /** |
||
41 | * SQL query. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const SQL_QUERY = <<< EOT |
||
46 | SELECT |
||
47 | '%entity%' AS 'entity', |
||
48 | '%field%' AS 'field', |
||
49 | %available% AS 'available', |
||
50 | MIN(LENGTH(`%column%`)) AS 'minimum', |
||
51 | MAX(LENGTH(`%column%`)) AS 'maximum', |
||
52 | AVG(LENGTH(`%column%`)) AS 'average', |
||
53 | COUNT(`%column%`) AS 'count' |
||
54 | FROM `%table%` |
||
55 | EOT; |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param EntityManagerInterface $entityManager The entity manager. |
||
61 | */ |
||
62 | public function __construct(EntityManagerInterface $entityManager) { |
||
65 | |||
66 | /** |
||
67 | * Execute a statement. |
||
68 | * |
||
69 | * @param Statement $statement The statement. |
||
70 | * @return RepositoryReport|null Returns the repository report in case of success, null otherwise. |
||
71 | */ |
||
72 | protected function executeStatement(Statement $statement) { |
||
92 | |||
93 | /** |
||
94 | * Get a repository report sort closure. |
||
95 | * |
||
96 | * @return Closure Returns the repository report sort closure. |
||
97 | */ |
||
98 | public static function getRepositoryReportSortClosure() { |
||
109 | |||
110 | /** |
||
111 | * Prepare a statement. |
||
112 | * |
||
113 | * @param string $table The table. |
||
114 | * @param string $entity The entity. |
||
115 | * @param string $field The field. |
||
116 | * @param int $available The available. |
||
117 | * @param string $column The column. |
||
118 | * @return Statement Returns the statement. |
||
119 | * @throws DBALException Throws a DBAL exception. |
||
120 | */ |
||
121 | protected function prepareStatement($table, $entity, $field, $available, $column) { |
||
130 | |||
131 | /** |
||
132 | * Read the reposotories. |
||
133 | * |
||
134 | * @return RepositoryReport[] Returns the repository reports. |
||
135 | * @throws DBALException Throws a DBAL exception. |
||
136 | * @throws MappingException Throws a mapping exception. |
||
137 | */ |
||
138 | public function readRepositories() { |
||
157 | |||
158 | /** |
||
159 | * Read a repository. |
||
160 | * |
||
161 | * @param ClassMetadata $classMetadata The class metadata. |
||
162 | * @return RepositoryReport[] Returns the repository reports. |
||
163 | * @throws DBALException Throws a DBAL exception. |
||
164 | * @throws MappingException Throws a mapping exception. |
||
165 | */ |
||
166 | protected function readRepository(ClassMetadata $classMetadata) { |
||
193 | } |
||
194 |