Conditions | 3 |
Paths | 4 |
Total Lines | 56 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
23 | public static function setUpBeforeClass() |
||
24 | { |
||
25 | if (!is_dir('/tmp/dtcqueuetest/generate/proxies')) { |
||
26 | mkdir('/tmp/dtcqueuetest/generate/proxies', 0777, true); |
||
27 | } |
||
28 | |||
29 | $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.'/../..'), true, null, null, false); |
||
30 | |||
31 | AnnotationRegistry::registerFile(__DIR__.'/../../vendor/mmucklo/grid-bundle/Annotation/Grid.php'); |
||
32 | AnnotationRegistry::registerFile(__DIR__.'/../../vendor/mmucklo/grid-bundle/Annotation/ShowAction.php'); |
||
33 | AnnotationRegistry::registerFile(__DIR__.'/../../vendor/mmucklo/grid-bundle/Annotation/DeleteAction.php'); |
||
34 | AnnotationRegistry::registerFile(__DIR__.'/../../vendor/mmucklo/grid-bundle/Annotation/Column.php'); |
||
35 | AnnotationRegistry::registerFile(__DIR__.'/../../vendor/mmucklo/grid-bundle/Annotation/Action.php'); |
||
36 | |||
37 | $namingStrategy = new UnderscoreNamingStrategy(); |
||
38 | $config->setNamingStrategy($namingStrategy); |
||
39 | $host = getenv('MYSQL_HOST'); |
||
40 | $user = getenv('MYSQL_USER'); |
||
41 | $port = getenv('MYSQL_PORT') ?: 3306; |
||
42 | $password = getenv('MYSQL_PASSWORD'); |
||
43 | $db = getenv('MYSQL_DATABASE'); |
||
44 | $params = ['host' => $host, |
||
45 | 'port' => $port, |
||
46 | 'user' => $user, |
||
47 | 'driver' => 'mysqli', |
||
48 | 'password' => $password, |
||
49 | 'dbname' => $db, ]; |
||
50 | self::$entityManager = EntityManager::create($params, $config); |
||
51 | |||
52 | $entityName = 'Dtc\QueueBundle\Entity\Job'; |
||
53 | $archiveEntityName = 'Dtc\QueueBundle\Entity\JobArchive'; |
||
54 | $runClass = 'Dtc\QueueBundle\Entity\Run'; |
||
55 | $runArchiveClass = 'Dtc\QueueBundle\Entity\RunArchive'; |
||
56 | |||
57 | $tool = new SchemaTool(self::$entityManager); |
||
58 | $metadataEntity = [self::$entityManager->getClassMetadata($entityName)]; |
||
59 | $tool->dropSchema($metadataEntity); |
||
60 | $tool->createSchema($metadataEntity); |
||
61 | |||
62 | $metadataEntityArchive = [self::$entityManager->getClassMetadata($archiveEntityName)]; |
||
63 | $tool->dropSchema($metadataEntityArchive); |
||
64 | $tool->createSchema($metadataEntityArchive); |
||
65 | |||
66 | $metadataEntityRun = [self::$entityManager->getClassMetadata($runClass)]; |
||
67 | $tool->dropSchema($metadataEntityRun); |
||
68 | $tool->createSchema($metadataEntityRun); |
||
69 | |||
70 | $metadataEntityRunArchive = [self::$entityManager->getClassMetadata($runArchiveClass)]; |
||
71 | $tool->dropSchema($metadataEntityRunArchive); |
||
72 | $tool->createSchema($metadataEntityRunArchive); |
||
73 | |||
74 | self::$jobManager = new JobManager(self::$entityManager, $entityName, $archiveEntityName, $runClass, $runArchiveClass); |
||
75 | self::$worker = new FibonacciWorker(); |
||
76 | self::$worker->setJobClass($entityName); |
||
77 | parent::setUpBeforeClass(); |
||
78 | } |
||
79 | } |
||
80 |