Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/PostVote.php 1 location

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

src/PlaygroundGame/Service/Game.php 1 location

@@ 1923-1952 (lines=30) @@
1920
     * @param array $data
1921
     * @return \PlaygroundGame\Entity\Game
1922
     */
1923
    public function createForm(array $data, $game, $form = null)
1924
    {
1925
        $title = '';
1926
        $description = '';
1927
1928
        if ($data['form_jsonified']) {
1929
            $jsonPV = json_decode($data['form_jsonified']);
1930
            foreach ($jsonPV as $element) {
1931
                if ($element->form_properties) {
1932
                    $attributes = $element->form_properties[0];
1933
                    $title = $attributes->title;
1934
                    $description = $attributes->description;
1935
1936
                    break;
1937
                }
1938
            }
1939
        }
1940
        if (! $form) {
1941
            $form = new \PlaygroundGame\Entity\PlayerForm();
1942
        }
1943
        $form->setGame($game);
1944
        $form->setTitle($title);
1945
        $form->setDescription($description);
1946
        $form->setForm($data['form_jsonified']);
1947
        $form->setFormTemplate($data['form_template']);
1948
1949
        $form = $this->getPlayerFormMapper()->insert($form);
1950
1951
        return $form;
1952
    }
1953
1954
    /**
1955
     *  getCSV creates lines of CSV and returns it.