Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/Game.php 1 location

@@ 1622-1651 (lines=30) @@
1619
     * @param array $data
1620
     * @return \PlaygroundGame\Entity\Game
1621
     */
1622
    public function createForm(array $data, $game, $form = null)
1623
    {
1624
        $title = '';
1625
        $description = '';
1626
1627
        if ($data['form_jsonified']) {
1628
            $jsonPV = json_decode($data['form_jsonified']);
1629
            foreach ($jsonPV as $element) {
1630
                if ($element->form_properties) {
1631
                    $attributes = $element->form_properties[0];
1632
                    $title = $attributes->title;
1633
                    $description = $attributes->description;
1634
1635
                    break;
1636
                }
1637
            }
1638
        }
1639
        if (! $form) {
1640
            $form = new \PlaygroundGame\Entity\PlayerForm();
1641
        }
1642
        $form->setGame($game);
1643
        $form->setTitle($title);
1644
        $form->setDescription($description);
1645
        $form->setForm($data['form_jsonified']);
1646
        $form->setFormTemplate($data['form_template']);
1647
1648
        $form = $this->getPlayerFormMapper()->insert($form);
1649
1650
        return $form;
1651
    }
1652
1653
    /**
1654
     *  getCSV creates lines of CSV and returns it.

src/PlaygroundGame/Service/PostVote.php 1 location

@@ 264-293 (lines=30) @@
261
     * @param  array                  $data
262
     * @return \PlaygroundGame\Entity\Game
263
     */
264
    public function createForm(array $data, $game, $form = null)
265
    {
266
        $title ='';
267
        $description = '';
268
269
        if ($data['form_jsonified']) {
270
            $jsonPV = json_decode($data['form_jsonified']);
271
            foreach ($jsonPV as $element) {
272
                if ($element->form_properties) {
273
                    $attributes  = $element->form_properties[0];
274
                    $title       = $attributes->title;
275
                    $description = $attributes->description;
276
277
                    break;
278
                }
279
            }
280
        }
281
        if (!$form) {
282
            $form = new \PlaygroundGame\Entity\PostVoteForm();
283
        }
284
        $form->setPostvote($game);
285
        $form->setTitle($title);
286
        $form->setDescription($description);
287
        $form->setForm($data['form_jsonified']);
288
        $form->setFormTemplate($data['form_template']);
289
290
        $form = $this->getPostVoteFormMapper()->insert($form);
291
292
        return $form;
293
    }
294
295
    public function findArrayOfValidatedPosts($game, $filter, $search = '')
296
    {