Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/PostVote.php 1 location

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

src/PlaygroundGame/Service/Game.php 1 location

@@ 1837-1866 (lines=30) @@
1834
     * @param array $data
1835
     * @return \PlaygroundGame\Entity\Game
1836
     */
1837
    public function createForm(array $data, $game, $form = null)
1838
    {
1839
        $title = '';
1840
        $description = '';
1841
1842
        if ($data['form_jsonified']) {
1843
            $jsonPV = json_decode($data['form_jsonified']);
1844
            foreach ($jsonPV as $element) {
1845
                if ($element->form_properties) {
1846
                    $attributes = $element->form_properties[0];
1847
                    $title = $attributes->title;
1848
                    $description = $attributes->description;
1849
1850
                    break;
1851
                }
1852
            }
1853
        }
1854
        if (! $form) {
1855
            $form = new \PlaygroundGame\Entity\PlayerForm();
1856
        }
1857
        $form->setGame($game);
1858
        $form->setTitle($title);
1859
        $form->setDescription($description);
1860
        $form->setForm($data['form_jsonified']);
1861
        $form->setFormTemplate($data['form_template']);
1862
1863
        $form = $this->getPlayerFormMapper()->insert($form);
1864
1865
        return $form;
1866
    }
1867
1868
    /**
1869
     *  getCSV creates lines of CSV and returns it.