Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F10813364
ServiceReportEntry.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
ServiceReportEntry.php
View Options
<?php
namespace
Nasqueron\Notifications\Config\Reporting
;
use
Nasqueron\Notifications\Config\Services\Service
;
use
ProjectsMap
;
final
class
ServiceReportEntry
extends
BaseReportEntry
{
///
/// Private members
///
/**
* @var Service
*/
private
$service
;
///
/// Public properties
///
/**
* @var string
*/
public
$gate
;
/**
* @var string
*/
public
$door
;
/**
* @var string
*/
public
$instance
;
/**
* @var string
*/
public
$status
=
""
;
///
/// Constructor
///
/**
* Initializes a new instance of the ServiceReportEntry class.
*
* @param \Nasqueron\Notifications\Config\Services\Service $service The service
*/
public
function
__construct
(
Service
$service
)
{
$this
->
service
=
$service
;
$this
->
query
();
}
///
/// Report builder
///
/**
* Queries the service to fill public properties.
*/
protected
function
query
()
:
void
{
// Direct properties
$this
->
gate
=
$this
->
service
->
gate
;
$this
->
door
=
$this
->
service
->
door
;
$this
->
instance
=
(
string
)
$this
->
service
->
instance
;
// Properties to query with business logic
$this
->
status
=
$this
->
getServiceStatus
();
}
/**
* @return string An issue to fix, or an empty string if all looks good.
*/
protected
function
getServiceStatus
()
:
string
{
if
(
$this
->
isPhabricatorServiceWithNotCachedProjectsMap
())
{
return
"Projects map not cached."
;
}
return
""
;
}
/**
* Determines if the service matches the following issue to report:
* - service is Phabricator
* - instance doesn't have the projects' name/PHID map in cache
*
* @return bool
*/
protected
function
isPhabricatorServiceWithNotCachedProjectsMap
()
:
bool
{
if
(
$this
->
service
->
gate
!==
'Phabricator'
)
{
return
false
;
}
$map
=
ProjectsMap
::
fetch
(
$this
->
service
->
door
);
return
!
$map
->
isCached
();
}
///
/// Format
///
/**
* Gets the entry as an array. Formats empty string.
*
* @return string[]
*/
public
function
toArray
()
:
array
{
return
[
$this
->
gate
,
$this
->
door
,
$this
->
instance
,
$this
->
status
,
];
}
/**
* Gets the entry as an array. Formats empty string.
*
* @return string[]
*/
public
function
toFancyArray
()
:
array
{
return
[
$this
->
gate
,
$this
->
door
,
self
::
fancyString
(
$this
->
instance
,
'ø'
),
self
::
fancyString
(
$this
->
status
,
'✓'
),
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jul 29, 13:52 (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2832671
Default Alt Text
ServiceReportEntry.php (2 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment