Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10813526
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
*
* @return string
*/
public
function
getWhere
()
{
$repo
=
$this
->
payload
->
repository
->
name
;
$branch
=
$this
->
payload
->
ref
;
return
static
::
getRepositoryAndBranch
(
$repo
,
$branch
);
}
/**
* Gets a repository and branch information string
*
* @param string $repo The repository
* @param string $branch The branch
* @return string "<repo>" or "<repo> (branch <branch>)" when branch isn't master
*/
public
static
function
getRepositoryAndBranch
(
$repo
=
""
,
$branch
=
""
)
{
if
(
$repo
===
""
)
{
return
""
;
}
if
(
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
Tue, Jul 29, 13:55 (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2821997
Default Alt Text
WithRepoAndBranch.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment