Code Duplication    Length = 30-30 lines in 2 locations

src/PlaygroundGame/Service/PostVote.php 1 location

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

src/PlaygroundGame/Service/Game.php 1 location

@@ 1949-1978 (lines=30) @@
1946
     * @param array $data
1947
     * @return \PlaygroundGame\Entity\Game
1948
     */
1949
    public function createForm(array $data, $game, $form = null)
1950
    {
1951
        $title = '';
1952
        $description = '';
1953
1954
        if ($data['form_jsonified']) {
1955
            $jsonPV = json_decode($data['form_jsonified']);
1956
            foreach ($jsonPV as $element) {
1957
                if ($element->form_properties) {
1958
                    $attributes = $element->form_properties[0];
1959
                    $title = $attributes->title;
1960
                    $description = $attributes->description;
1961
1962
                    break;
1963
                }
1964
            }
1965
        }
1966
        if (! $form) {
1967
            $form = new \PlaygroundGame\Entity\PlayerForm();
1968
        }
1969
        $form->setGame($game);
1970
        $form->setTitle($title);
1971
        $form->setDescription($description);
1972
        $form->setForm($data['form_jsonified']);
1973
        $form->setFormTemplate($data['form_template']);
1974
1975
        $form = $this->getPlayerFormMapper()->insert($form);
1976
1977
        return $form;
1978
    }
1979
1980
    /**
1981
     *  getCSV creates lines of CSV and returns it.