GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SeederHelper   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B saveData() 0 41 6
1
<?php
2
3
namespace Elimuswift\DbExporter;
4
5
trait SeederHelper
6
{
7
    
8
    public function saveData($table, $item) 
9
    {
10
    	// If have primary id
11
    	if(isset($item['id'])) 
12
    	{
13
    		if(\DB::table($table)->where('id', $item['id'])->count() > 0) 
14
    		{
15
    			\DB::table($table)->where('id', $item['id'])->update($item);
16
    		} 
17
    		else 
18
    		{
19
    			\DB::table($table)->insert($item);
20
    		}
21
        } 
22
        else 
23
        {
24
        	$ids = collect($item)->filter(function($item, $key) {
25
        		return str_contains($key, '_id');
26
        	})->keys()->values();
27
28
        	// If there isnt any column with _id, so check that every column matches
29
        	if($ids->count() <= 0) {
30
        		$ids = collect($item)->keys()->values();
31
        	}
32
        	$object = \DB::table($table);
33
        	foreach ($ids as $id) {
34
        		$object = $object->where($id, $item[$id]);
35
        	}
36
37
        	// save or update
38
        	if($object->count() > 0) 
39
    		{
40
    			$object->update($item);
41
    		} 
42
    		else 
43
    		{
44
    			$object->insert($item);
45
    		}
46
        	
47
        }
48
    }   
49
}
50