Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F9503048
WithRepoAndBranch.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
WithRepoAndBranch.php
View Options
<?php
namespace
Nasqueron\Notifications\Analyzers\GitHub\Events
;
/**
* Helper methods for events with a need to specify the repo and the branch
* (e.g. push)
*
* @link https://developer.github.com/v3/activity/events/types/#pushevent
*/
trait
WithRepoAndBranch
{
/**
* Gets repository and branch information
*/
public
function
getWhere
()
:
string
{
$repo
=
$this
->
payload
->
repository
->
name
;
$branch
=
$this
->
payload
->
ref
;
return
static
::
getRepositoryAndBranch
(
$repo
,
$branch
);
}
public
static
function
getRepositoryAndBranch
(
$repo
=
""
,
$branch
=
""
)
:
string
{
if
(
$repo
===
""
)
{
return
""
;
}
if
(
str_starts_with
(
$branch
,
"refs/heads/"
))
{
$branch
=
substr
(
$branch
,
11
);
}
if
(
$branch
===
""
||
$branch
===
"master"
)
{
return
$repo
;
}
return
trans
(
'GitHub.RepoAndBranch'
,
[
'repo'
=>
$repo
,
'branch'
=>
$branch
,
]);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jun 8, 00:19 (10 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700269
Default Alt Text
WithRepoAndBranch.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment