Code Duplication    Length = 30-30 lines in 2 locations

src/Service/Game.php 1 location

@@ 2026-2055 (lines=30) @@
2023
     * @param array $data
2024
     * @return \PlaygroundGame\Entity\Game
2025
     */
2026
    public function createForm(array $data, $game, $form = null)
2027
    {
2028
        $title = '';
2029
        $description = '';
2030
2031
        if ($data['form_jsonified']) {
2032
            $jsonPV = json_decode($data['form_jsonified']);
2033
            foreach ($jsonPV as $element) {
2034
                if ($element->form_properties) {
2035
                    $attributes = $element->form_properties[0];
2036
                    $title = $attributes->title;
2037
                    $description = $attributes->description;
2038
2039
                    break;
2040
                }
2041
            }
2042
        }
2043
        if (! $form) {
2044
            $form = new \PlaygroundGame\Entity\PlayerForm();
2045
        }
2046
        $form->setGame($game);
2047
        $form->setTitle($title);
2048
        $form->setDescription($description);
2049
        $form->setForm($data['form_jsonified']);
2050
        $form->setFormTemplate($data['form_template']);
2051
2052
        $form = $this->getPlayerFormMapper()->insert($form);
2053
2054
        return $form;
2055
    }
2056
2057
    /**
2058
     *  getCSV creates lines of CSV and returns it.

src/Service/PostVote.php 1 location

@@ 278-307 (lines=30) @@
275
     * @param  array                  $data
276
     * @return \PlaygroundGame\Entity\Game
277
     */
278
    public function createForm(array $data, $game, $form = null)
279
    {
280
        $title ='';
281
        $description = '';
282
283
        if ($data['form_jsonified']) {
284
            $jsonPV = json_decode($data['form_jsonified']);
285
            foreach ($jsonPV as $element) {
286
                if ($element->form_properties) {
287
                    $attributes  = $element->form_properties[0];
288
                    $title       = $attributes->title;
289
                    $description = $attributes->description;
290
291
                    break;
292
                }
293
            }
294
        }
295
        if (!$form) {
296
            $form = new \PlaygroundGame\Entity\PostVoteForm();
297
        }
298
        $form->setPostvote($game);
299
        $form->setTitle($title);
300
        $form->setDescription($description);
301
        $form->setForm($data['form_jsonified']);
302
        $form->setFormTemplate($data['form_template']);
303
304
        $form = $this->getPostVoteFormMapper()->insert($form);
305
306
        return $form;
307
    }
308
309
    public function findArrayOfValidatedPosts($game, $user, $filter, $search = '')
310
    {