Code Duplication    Length = 17-17 lines in 2 locations

src/DoctrineMigrations/Version20131015113854_ChangeImagePaths.php 2 locations

@@ 72-88 (lines=17) @@
69
                `cover` != "" AND
70
                `cover`  NOT LIKE "example/%"'
71
        );
72
        foreach ($items as $item) {
73
            $path = date('Y/m/d/His/', strtotime($item['date_add']));
74
            $file = new File($this->media_dir.$item['cover']);
75
            $file->move($this->media_dir.$path);
76
            $this->addSql('
77
                UPDATE
78
                    `item`
79
                SET
80
                    `cover` = ?
81
                WHERE
82
                    `id` = ?',
83
                [
84
                    $path.$file->getBasename(),
85
                    $item['id'],
86
                ]
87
            );
88
        }
89
90
        // move images
91
        $images = $this->connection->fetchAll('
@@ 103-119 (lines=17) @@
100
                ON
101
                    im.`item` = i.`id`'
102
        );
103
        foreach ($images as $image) {
104
            $path = date('Y/m/d/His/', strtotime($image['date_add']));
105
            $file = new File($this->media_dir.$image['source']);
106
            $file->move($this->media_dir.$path);
107
            $this->addSql('
108
                UPDATE
109
                    `image`
110
                SET
111
                    `source` = ?
112
                WHERE
113
                    `id` = ?',
114
                [
115
                    $path.$file->getBasename(),
116
                    $image['id'],
117
                ]
118
            );
119
        }
120
121
        // skip if no data
122
        $this->skipIf(!($items && $images), 'No data to migrate');