Code Duplication    Length = 30-30 lines in 2 locations

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, $user, $filter, $search = '')
296
    {

src/PlaygroundGame/Service/Game.php 1 location

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