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

@@ 1703-1732 (lines=30) @@
1700
     * @param array $data
1701
     * @return \PlaygroundGame\Entity\Game
1702
     */
1703
    public function createForm(array $data, $game, $form = null)
1704
    {
1705
        $title = '';
1706
        $description = '';
1707
1708
        if ($data['form_jsonified']) {
1709
            $jsonPV = json_decode($data['form_jsonified']);
1710
            foreach ($jsonPV as $element) {
1711
                if ($element->form_properties) {
1712
                    $attributes = $element->form_properties[0];
1713
                    $title = $attributes->title;
1714
                    $description = $attributes->description;
1715
1716
                    break;
1717
                }
1718
            }
1719
        }
1720
        if (! $form) {
1721
            $form = new \PlaygroundGame\Entity\PlayerForm();
1722
        }
1723
        $form->setGame($game);
1724
        $form->setTitle($title);
1725
        $form->setDescription($description);
1726
        $form->setForm($data['form_jsonified']);
1727
        $form->setFormTemplate($data['form_template']);
1728
1729
        $form = $this->getPlayerFormMapper()->insert($form);
1730
1731
        return $form;
1732
    }
1733
1734
    /**
1735
     *  getCSV creates lines of CSV and returns it.