Code Duplication    Length = 30-30 lines in 2 locations

src/Service/PostVote.php 1 location

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

src/Service/Game.php 1 location

@@ 1817-1846 (lines=30) @@
1814
     * @param array $data
1815
     * @return \PlaygroundGame\Entity\Game
1816
     */
1817
    public function createForm(array $data, $game, $form = null)
1818
    {
1819
        $title = '';
1820
        $description = '';
1821
1822
        if ($data['form_jsonified']) {
1823
            $jsonPV = json_decode($data['form_jsonified']);
1824
            foreach ($jsonPV as $element) {
1825
                if ($element->form_properties) {
1826
                    $attributes = $element->form_properties[0];
1827
                    $title = $attributes->title;
1828
                    $description = $attributes->description;
1829
1830
                    break;
1831
                }
1832
            }
1833
        }
1834
        if (! $form) {
1835
            $form = new \PlaygroundGame\Entity\PlayerForm();
1836
        }
1837
        $form->setGame($game);
1838
        $form->setTitle($title);
1839
        $form->setDescription($description);
1840
        $form->setForm($data['form_jsonified']);
1841
        $form->setFormTemplate($data['form_template']);
1842
1843
        $form = $this->getPlayerFormMapper()->insert($form);
1844
1845
        return $form;
1846
    }
1847
1848
    /**
1849
     *  getCSV creates lines of CSV and returns it.