Code Duplication    Length = 30-35 lines in 2 locations

Overflowable.php 1 location

@@ 6-40 (lines=35) @@
3
namespace CraftLogan\LaravelOverflow;
4
use Illuminate\Support\Facades\Schema;
5
6
trait Overflowable{
7
8
    public function allWithOverflow()
9
    {
10
        $properties[$this->overflow_column] = $this->overflow();
11
        return array_merge($properties, $this->getColumns());
12
    }
13
14
    public function getColumns()
15
    {
16
        $columnNames = $this->getColumnNames();
17
        $attributes = array_intersect_key($this->all(), $columnNames);
18
        return $attributes;
19
    }
20
21
    public function overflow()
22
    {
23
        $columnNames = $this->getColumnNames();
24
        $attributes = array_diff_key($this->all(), $columnNames);
25
        $attributes = json_encode($attributes);
26
        return $attributes;
27
    }
28
29
    public function getTableColumns()
30
    {
31
        return Schema::getColumnListing($this->table);
32
    }
33
34
    public function getColumnNames()
35
    {
36
        $columnNames = $this->getTableColumns();
37
        $columnNames = array_fill_keys($columnNames, "");
38
        return $columnNames;
39
    }
40
}
41

src/Overflowable.php 1 location

@@ 6-35 (lines=30) @@
3
namespace CraftLogan\LaravelOverflow;
4
use Illuminate\Support\Facades\Schema;
5
6
trait Overflowable{
7
8
    public function allWithOverflow()
9
    {
10
        $properties[$this->overflow_column] = $this->overflow();
11
        return array_merge($properties, $this->getColumns());
12
    }
13
14
    public function getColumns()
15
    {
16
        $columnNames = $this->getTableColumns();
17
        $columnNames = array_fill_keys($columnNames, "");
18
        $attributes = array_intersect_key($this->all(), $columnNames);
19
        return $attributes;
20
    }
21
22
    public function overflow()
23
    {
24
        $columnNames = $this->getTableColumns();
25
        $columnNames = array_fill_keys($columnNames, "");
26
        $attributes = array_diff_key($this->all(), $columnNames);
27
        $attributes = json_encode($attributes);
28
        return $attributes;
29
    }
30
31
    public function getTableColumns()
32
    {
33
        return Schema::getColumnListing($this->table);
34
    }
35
}
36