Completed
Push — master ( e161e0...db8b9c )
by Tim
20s queued 10s
created

CalendarizeField   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 4 1
A getCalendarizeDatabaseString() 0 9 2
1
<?php
2
declare(strict_types=1);
3
4
namespace HDNET\Calendarize\Listener;
5
6
use HDNET\Calendarize\Register;
7
use TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent;
8
9
class CalendarizeField
10
{
11
    public function __invoke(AlterTableDefinitionStatementsEvent $event): void
12
    {
13
        $event->addSqlData($this->getCalendarizeDatabaseString());
14
    }
15
16
    /**
17
     * Get the calendarize string for the registered tables.
18
     *
19
     * @return string
20
     */
21
    protected function getCalendarizeDatabaseString()
22
    {
23
        $sql = [];
24
        foreach (Register::getRegister() as $configuration) {
25
            $sql[] = 'CREATE TABLE ' . $configuration['tableName'] . ' (calendarize tinytext);';
26
        }
27
28
        return \implode(LF, $sql);
29
    }
30
}
31