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

@@ 2026-2055 (lines=30) @@
2023
     * @param array $data
2024
     * @return \PlaygroundGame\Entity\Game
2025
     */
2026
    public function createForm(array $data, $game, $form = null)
2027
    {
2028
        $title = '';
2029
        $description = '';
2030
2031
        if ($data['form_jsonified']) {
2032
            $jsonPV = json_decode($data['form_jsonified']);
2033
            foreach ($jsonPV as $element) {
2034
                if ($element->form_properties) {
2035
                    $attributes = $element->form_properties[0];
2036
                    $title = $attributes->title;
2037
                    $description = $attributes->description;
2038
2039
                    break;
2040
                }
2041
            }
2042
        }
2043
        if (! $form) {
2044
            $form = new \PlaygroundGame\Entity\PlayerForm();
2045
        }
2046
        $form->setGame($game);
2047
        $form->setTitle($title);
2048
        $form->setDescription($description);
2049
        $form->setForm($data['form_jsonified']);
2050
        $form->setFormTemplate($data['form_template']);
2051
2052
        $form = $this->getPlayerFormMapper()->insert($form);
2053
2054
        return $form;
2055
    }
2056
2057
    /**
2058
     *  getCSV creates lines of CSV and returns it.