Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12238861
RepositoryEvent.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
RepositoryEvent.php
View Options
<?php
namespace
Nasqueron\Notifications\Analyzers\GitHub\Events
;
/**
* RepositoryEvent payload analyzer
*
* @link https://developer.github.com/v3/activity/events/types/#repositoryevent
*/
class
RepositoryEvent
extends
Event
{
/**
* Determines if the action is valid.
*
* @param string $action The action to check
* @return bool true if the action is valid; otherwise, false
*/
protected
static
function
isValidAction
(
string
$action
)
:
bool
{
$actions
=
[
'created'
,
'deleted'
,
'publicized'
,
'privatized'
];
return
in_array
(
$action
,
$actions
);
}
/**
* Gets description for the payload
*/
public
function
getDescription
()
:
string
{
$action
=
$this
->
payload
->
action
;
if
(!
static
::
isValidAction
(
$action
))
{
return
trans
(
'GitHub.EventsDescriptions.RepositoryEventUnknown'
,
[
'action'
=>
$action
]
);
}
$key
=
'GitHub.EventsDescriptions.RepositoryEventPerAction.'
;
$key
.=
$action
;
$repository
=
$this
->
payload
->
repository
->
full_name
;
$message
=
trans
(
$key
,
[
'repository'
=>
$repository
]);
if
(
$this
->
payload
->
repository
->
fork
)
{
$message
.=
trans
(
'GitHub.EventsDescriptions.RepositoryEventFork'
);
}
$description
=
(
string
)
$this
->
payload
->
repository
->
description
;
if
(
$description
!==
""
)
{
$message
.=
trans
(
'GitHub.Separator'
);
$message
.=
$description
;
}
return
$message
;
}
/**
* Gets link for the payload
*/
public
function
getLink
()
:
string
{
return
$this
->
payload
->
repository
->
html_url
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 11, 19:58 (2 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3063763
Default Alt Text
RepositoryEvent.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment