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

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