Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/PostVote.php 1 location

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

src/PlaygroundGame/Service/Game.php 1 location

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