Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/PostVote.php 1 location

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

src/PlaygroundGame/Service/Game.php 1 location

@@ 1719-1748 (lines=30) @@
1716
     * @param array $data
1717
     * @return \PlaygroundGame\Entity\Game
1718
     */
1719
    public function createForm(array $data, $game, $form = null)
1720
    {
1721
        $title = '';
1722
        $description = '';
1723
1724
        if ($data['form_jsonified']) {
1725
            $jsonPV = json_decode($data['form_jsonified']);
1726
            foreach ($jsonPV as $element) {
1727
                if ($element->form_properties) {
1728
                    $attributes = $element->form_properties[0];
1729
                    $title = $attributes->title;
1730
                    $description = $attributes->description;
1731
1732
                    break;
1733
                }
1734
            }
1735
        }
1736
        if (! $form) {
1737
            $form = new \PlaygroundGame\Entity\PlayerForm();
1738
        }
1739
        $form->setGame($game);
1740
        $form->setTitle($title);
1741
        $form->setDescription($description);
1742
        $form->setForm($data['form_jsonified']);
1743
        $form->setFormTemplate($data['form_template']);
1744
1745
        $form = $this->getPlayerFormMapper()->insert($form);
1746
1747
        return $form;
1748
    }
1749
1750
    /**
1751
     *  getCSV creates lines of CSV and returns it.