Skip to content

Commit 2c6f397

Browse files
Add files via upload
1 parent 68f8b9b commit 2c6f397

File tree

3 files changed

+597
-0
lines changed

3 files changed

+597
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
namespace App\Classes;
4+
5+
use Illuminate\Support\Collection;
6+
7+
class PullRequest
8+
{
9+
public array $changedFiles = [];
10+
public array $checkedFiles = [];
11+
public array $comments = [];
12+
public array $uniqueComments = [];
13+
14+
public function changedFiles(array $pullRequests):Object
15+
{
16+
$arr = collect($pullRequests)->where('fileStatus','changed')->all();
17+
18+
$this->changedFiles = $arr;
19+
20+
return $this;
21+
}
22+
23+
public function checkFile():Object
24+
{
25+
26+
$res = collect($this->changedFiles)->filter(function($value) {
27+
28+
$exts = array('php','html','css','js');
29+
30+
$ext = substr(strrchr($value["filename"], '.'),1);
31+
32+
return in_array(substr(strrchr($value["filename"], '.'),1),$exts) == 1;
33+
34+
});
35+
36+
$this->checkedFiles = $res->toArray();
37+
38+
return $this;
39+
}
40+
41+
public function comments():Object
42+
{
43+
44+
$collectCheckedFiles = collect($this->checkedFiles);
45+
46+
$comments = $collectCheckedFiles->pluck('comments');
47+
48+
$this->comments = $comments->toArray();
49+
50+
return $this;
51+
52+
}
53+
54+
public function removeDuplicate():Object
55+
{
56+
$collComments = collect($this->comments);
57+
58+
$this->uniqueComments = $collComments->unique()->toArray();
59+
60+
return $this;
61+
62+
}
63+
64+
public function getNonEmpty():Collection
65+
{
66+
return collect($this->uniqueComments)->reject(null);
67+
}
68+
69+
70+
71+
}

0 commit comments

Comments
 (0)