Code Duplication    Length = 26-28 lines in 2 locations

src/OroCRM/Bundle/DemoDataBundle/Migrations/Data/Demo/ORM/LoadLeadsData.php 1 location

@@ 131-156 (lines=26) @@
128
            ->locateResource('@OroCRMDemoDataBundle/Migrations/Data/Demo/ORM/dictionaries');
129
130
        $handle = fopen($dictionaryDir . DIRECTORY_SEPARATOR. "leads.csv", "r");
131
        if ($handle) {
132
            $headers = array();
133
            if (($data = fgetcsv($handle, 1000, ",")) !== false) {
134
                //read headers
135
                $headers = $data;
136
            }
137
            $randomUser = count($this->users) - 1;
138
            $i = 0;
139
            while (($data = fgetcsv($handle, 1000, ",")) !== false) {
140
                $user = $this->users[mt_rand(0, $randomUser)];
141
                $this->setSecurityContext($user);
142
143
                $data = array_combine($headers, array_values($data));
144
145
                $lead = $this->createLead($manager, $data, $user);
146
                $this->persist($this->em, $lead);
147
148
                $i++;
149
                if ($i % self::FLUSH_MAX == 0) {
150
                    $this->flush($this->em);
151
                }
152
            }
153
154
            $this->flush($this->em);
155
            fclose($handle);
156
        }
157
    }
158
159
    /**

src/OroCRM/Bundle/ReportBundle/Tests/Functional/DataFixtures/LoadLeadsData.php 1 location

@@ 118-145 (lines=28) @@
115
    public function loadLeads(ObjectManager $manager)
116
    {
117
        $handle = fopen(__DIR__ . DIRECTORY_SEPARATOR . 'dictionaries' . DIRECTORY_SEPARATOR . "leads.csv", "r");
118
        if ($handle) {
119
            $headers = [];
120
            if (($data = fgetcsv($handle, 1000, ",")) !== false) {
121
                //read headers
122
                $headers = $data;
123
            }
124
            $randomUser = count($this->users) - 1;
125
            $i          = 0;
126
            while (($data = fgetcsv($handle, 1000, ",")) !== false) {
127
                $user = $this->users[mt_rand(0, $randomUser)];
128
                $this->setSecurityContext($user);
129
130
                $data = array_combine($headers, array_values($data));
131
132
                $lead = $this->createLead($manager, $data, $user);
133
                $this->em->persist($lead);
134
135
                $this->loadSalesFlows($lead);
136
137
                $i++;
138
                if ($i % self::FLUSH_MAX == 0) {
139
                    $this->em->flush();
140
                }
141
            }
142
143
            $this->em->flush();
144
            fclose($handle);
145
        }
146
    }
147
148
    /**