Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F9312954
WithRef.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
WithRef.php
View Options
<?php
namespace
Nasqueron\Notifications\Analyzers\GitHub\Events
;
/**
* References helper methods for events using ref and ref_type fields.
* (e.g. create and delete)
*
* @link https://developer.github.com/v3/activity/events/types/#createevent
* @link https://developer.github.com/v3/activity/events/types/#deleteevent
*/
trait
WithRef
{
/**
* Determines if the ref type is valid.
*
* The ref type 'repository' is deemed invalid, as we shouldn't receive it.
*
* @param string $type The ref type to check
* @return bool true if the ref type id valid; otherwise, false
*/
protected
static
function
isValidRefType
(
$type
)
{
$types
=
[
'branch'
,
'tag'
];
return
in_array
(
$type
,
$types
);
}
/**
* Gets link ref segment for the payload
*
* @param string $type The reference type
* @return string the part of the URL for this reference type (e.g. /tree/)
*/
protected
function
getLinkRefSegment
(
$type
)
{
$segments
=
$this
->
getLinkRefSegments
();
if
(!
array_key_exists
(
$type
,
$segments
))
{
throw
new
\InvalidArgumentException
;
}
return
$segments
[
$type
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 3, 01:45 (8 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2562039
Default Alt Text
WithRef.php (1 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment