callAddApprovedStudents   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A callFunction() 0 2 1
A addInstitutionStudents() 0 2 1
A __construct() 0 4 1
A handle() 0 5 1
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Models\Institution;
6
use Illuminate\Console\Command;
7
8
class callAddApprovedStudents extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'admission:run';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Command description';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
        $this->instituions = new Institution();
0 ignored issues
show
Bug Best Practice introduced by
The property instituions does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return mixed
39
     */
40
    public function handle()
41
    {
42
        ini_set('memory_limit','2048');
43
        $institutions = $this->instituions->all()->chunk(50)->toArray();
44
        array_walk($institutions,array($this,'addInstitutionStudents'));
45
    }
46
47
    protected function addInstitutionStudents($chunk){
48
        array_walk($chunk,array($this,'callFunction'));
49
50
    }
51
52
    protected function callFunction($institution){
53
        $this->call('admission:students',['institution' => $institution['code']]);
54
    }
55
}
56