Code Duplication    Length = 30-30 lines in 2 locations

src/Service/PostVote.php 1 location

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

src/Service/Game.php 1 location

@@ 1896-1925 (lines=30) @@
1893
     * @param array $data
1894
     * @return \PlaygroundGame\Entity\Game
1895
     */
1896
    public function createForm(array $data, $game, $form = null)
1897
    {
1898
        $title = '';
1899
        $description = '';
1900
1901
        if ($data['form_jsonified']) {
1902
            $jsonPV = json_decode($data['form_jsonified']);
1903
            foreach ($jsonPV as $element) {
1904
                if ($element->form_properties) {
1905
                    $attributes = $element->form_properties[0];
1906
                    $title = $attributes->title;
1907
                    $description = $attributes->description;
1908
1909
                    break;
1910
                }
1911
            }
1912
        }
1913
        if (! $form) {
1914
            $form = new \PlaygroundGame\Entity\PlayerForm();
1915
        }
1916
        $form->setGame($game);
1917
        $form->setTitle($title);
1918
        $form->setDescription($description);
1919
        $form->setForm($data['form_jsonified']);
1920
        $form->setFormTemplate($data['form_template']);
1921
1922
        $form = $this->getPlayerFormMapper()->insert($form);
1923
1924
        return $form;
1925
    }
1926
1927
    /**
1928
     *  getCSV creates lines of CSV and returns it.