Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Congressus API PHP
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Djojomoenawie, N.E. (Nathan, Student M-CS)
Congressus API PHP
Merge requests
!6
Test
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Test
test
into
main
Overview
0
Commits
6
Pipelines
0
Changes
7
Merged
Djojomoenawie, N.E. (Nathan, Student M-CS)
requested to merge
test
into
main
8 months ago
Overview
0
Commits
6
Pipelines
0
Changes
7
Expand
👍
0
👎
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
cc8f5434
6 commits,
8 months ago
7 files
+
1825
−
49
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Some changes are not shown
For a faster browsing experience, some files are collapsed by default.
Expand all files
Files
7
Search (e.g. *.vue) (Ctrl+P)
src/Page.php
+
134
−
22
Options
@@ -2,55 +2,167 @@
namespace
Compucie\Congressus
;
use
Compucie\Congressus\Model\PaginationMetadata
;
class
Page
extends
PaginationMetadata
class
Page
{
private
bool
$hasPrevious
;
private
?int
$previousPageNumber
;
private
bool
$hasNext
;
private
?int
$nextPageNumber
;
private
array
$data
;
private
int
$total
;
public
function
__construct
(
private
mixed
$pagination
,
private
string
$responseType
,
array
$responseBody
,
private
string
$caller
,
private
array
$parameters
,
)
{
parent
::
__construct
(
array
(
"total"
=>
$pagination
->
getTotal
(),
"previous_page"
=>
$pagination
->
getPrevNum
(),
"next_page"
=>
$pagination
->
getNextNum
(),
));
$this
->
setHasPrevious
(
$responseBody
[
"has_prev"
]);
$this
->
setPreviousPageNumber
(
$responseBody
[
"prev_num"
]);
$this
->
setHasNext
(
$responseBody
[
"has_next"
]);
$this
->
setNextPageNumber
(
$responseBody
[
"next_num"
]);
$this
->
setData
(
$responseBody
[
"data"
]);
$this
->
setTotal
(
$responseBody
[
"total"
]);
}
private
function
getPagination
():
mixed
/**
* Get the value of hasPrevious
*/
public
function
hasPrevious
():
bool
{
return
$this
->
pagination
;
return
$this
->
hasPrevious
;
}
/**
*
R
et
urn
the
client's method that was called to request this page.
*
S
et the
value of hasPrevious
*/
public
function
g
et
Caller
():
string
public
function
s
et
HasPrevious
(
bool
$hasPrevious
):
self
{
return
$this
->
caller
;
$this
->
hasPrevious
=
$hasPrevious
;
return
$this
;
}
/**
*
R
et
urn
the
parameters that yielded this page.
*
G
et the
value of previousPageNumber
*/
public
function
getP
aramet
er
s
():
array
public
function
getP
reviousPageNumb
er
():
int
{
return
$this
->
p
aramet
er
s
;
return
$this
->
p
reviousPageNumb
er
;
}
public
function
hasPrevious
():
bool
/**
* Set the value of previousPageNumber
*/
public
function
setPreviousPageNumber
(
?int
$previousPageNumber
):
self
{
return
$this
->
getPagination
()
->
getHasPrev
();;
$this
->
previousPageNumber
=
$previousPageNumber
;
return
$this
;
}
/**
* Get the value of hasNext
*/
public
function
hasNext
():
bool
{
return
$this
->
getPagination
()
->
getHasNext
();
return
$this
->
hasNext
;
}
/**
* Set the value of hasNext
*/
public
function
setHasNext
(
bool
$hasNext
):
self
{
$this
->
hasNext
=
$hasNext
;
return
$this
;
}
/**
* Get the value of nextPageNumber
*/
public
function
getNextPageNumber
():
int
{
return
$this
->
nextPageNumber
;
}
/**
* Set the value of nextPageNumber
*/
public
function
setNextPageNumber
(
?int
$nextPageNumber
):
self
{
$this
->
nextPageNumber
=
$nextPageNumber
;
return
$this
;
}
/**
* Get the value of data
*/
public
function
getData
():
array
{
return
$this
->
data
;
}
/**
* Set the value of data
*/
public
function
setData
(
array
$data
):
void
{
$elementType
=
array_fill
(
0
,
count
(
$data
),
str_replace
(
"Pagination"
,
""
,
$this
->
getResponseType
())
);
$this
->
data
=
array_map
([
$this
,
'buildObjectArray'
],
$elementType
,
$data
);
}
/**
* Get the value of total
*/
public
function
getTotal
():
int
{
return
$this
->
total
;
}
/**
* Set the value of total
*/
public
function
setTotal
(
int
$total
):
self
{
$this
->
total
=
$total
;
return
$this
;
}
/**
* Get the value of responseType
*/
public
function
getResponseType
():
string
{
return
$this
->
responseType
;
}
/**
* Get the value of caller
*/
public
function
getCaller
():
string
{
return
$this
->
caller
;
}
/**
* Get the value of parameters
*/
public
function
getParameters
():
array
{
return
$this
->
parameters
;
}
p
ubl
ic
function
getData
(
):
mixed
p
rivate
stat
ic
function
buildObjectArray
(
$type
,
$element
):
mixed
{
return
$this
->
getPagination
()
->
getData
(
);
return
new
$type
(
$element
);
}
}
Loading