Code Duplication    Length = 30-30 lines in 2 locations

src/Service/PostVote.php 1 location

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

src/Service/Game.php 1 location

@@ 1771-1800 (lines=30) @@
1768
     * @param array $data
1769
     * @return \PlaygroundGame\Entity\Game
1770
     */
1771
    public function createForm(array $data, $game, $form = null)
1772
    {
1773
        $title = '';
1774
        $description = '';
1775
1776
        if ($data['form_jsonified']) {
1777
            $jsonPV = json_decode($data['form_jsonified']);
1778
            foreach ($jsonPV as $element) {
1779
                if ($element->form_properties) {
1780
                    $attributes = $element->form_properties[0];
1781
                    $title = $attributes->title;
1782
                    $description = $attributes->description;
1783
1784
                    break;
1785
                }
1786
            }
1787
        }
1788
        if (! $form) {
1789
            $form = new \PlaygroundGame\Entity\PlayerForm();
1790
        }
1791
        $form->setGame($game);
1792
        $form->setTitle($title);
1793
        $form->setDescription($description);
1794
        $form->setForm($data['form_jsonified']);
1795
        $form->setFormTemplate($data['form_template']);
1796
1797
        $form = $this->getPlayerFormMapper()->insert($form);
1798
1799
        return $form;
1800
    }
1801
1802
    /**
1803
     *  getCSV creates lines of CSV and returns it.