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

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