Skip to content

Commit

Permalink
update endpoints and codesniffer beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed May 29, 2024
1 parent aeeba65 commit 3fed7bf
Show file tree
Hide file tree
Showing 11 changed files with 409 additions and 366 deletions.
64 changes: 32 additions & 32 deletions includes/Festivity.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
<?php
include_once( 'includes/enums/LitColor.php' );
include_once( 'includes/enums/LitCommon.php' );
include_once( 'includes/enums/LitFeastType.php' );
include_once( 'includes/enums/LitGrade.php' );

/**
include_once('includes/enums/LitColor.php');
include_once('includes/enums/LitCommon.php');
include_once('includes/enums/LitFeastType.php');
include_once('includes/enums/LitGrade.php');

/**
* CLASS FESTIVITY
* SIMILAR TO THE CLASS USED IN THE LITCAL PHP ENGINE,
* EXCEPT THAT IT CONVERTS PHP TIMESTAMP TO DATETIME OBJECT
* SIMILAR TO THE CLASS USED IN THE LITCAL PHP ENGINE,
* EXCEPT THAT IT CONVERTS PHP TIMESTAMP TO DATETIME OBJECT
* AND DOES NOT IMPLEMENT JSONSERIALIZABLE OR COMPARATOR FUNCTION
**/
class Festivity
{
public string $tag;
public string $name;
public DateTime $date;
public array $color;
public string $type;
public int $grade;
public string $displayGrade;
public array $common;
public string $liturgicalYear;
public bool $isVigilMass;
public string $tag;
public string $name;
public DateTime $date;
public array $color;
public string $type;
public int $grade;
public string $displayGrade;
public array $common;
public string $liturgicalYear;
public bool $isVigilMass;

function __construct( array $festivity ) {
public function __construct(array $festivity)
{
$this->name = $festivity["name"];
$this->date = DateTime::createFromFormat( 'U', $festivity["date"], new DateTimeZone( 'UTC' ) );
if( is_array( $festivity["color"] ) ) {
if( LitColor::areValid( $festivity["color"] ) ) {
$this->date = DateTime::createFromFormat('U', $festivity["date"], new DateTimeZone('UTC'));
if (is_array($festivity["color"])) {
if (LitColor::areValid($festivity["color"])) {
$this->color = $festivity["color"];
}
}
else if ( is_string( $festivity["color"] ) ) {
$_color = strtolower( $festivity["color"] );
} elseif (is_string($festivity["color"])) {
$_color = strtolower($festivity["color"]);
//the color string can contain multiple colors separated by a comma, when there are multiple commons to choose from for that festivity
$this->color = strpos( $_color, "," ) && LitColor::areValid( explode(",", $_color) ) ? explode(",", $_color) : ( LitColor::isValid( $_color ) ? [ $_color ] : [ '???' ] );
$this->color = strpos($_color, ",") && LitColor::areValid(explode(",", $_color)) ? explode(",", $_color) : ( LitColor::isValid($_color) ? [ $_color ] : [ '???' ] );
}
$this->type = LitFeastType::isValid( $festivity["type"] ) ? $festivity["type"] : "";
$this->grade = LitGrade::isValid( $festivity["grade"] ) ? $festivity["grade"] : -1;
$this->type = LitFeastType::isValid($festivity["type"]) ? $festivity["type"] : "";
$this->grade = LitGrade::isValid($festivity["grade"]) ? $festivity["grade"] : -1;
$this->displayGrade = $festivity["displayGrade"];
if( is_string( $festivity["common"] ) ) {
if (is_string($festivity["common"])) {
//Festivity::debugWrite( "*** Festivity.php *** common vartype is string, value = $festivity["common"]" );
$this->common = LitCommon::areValid( explode(",", $festivity["common"]) ) ? explode(",", $festivity["common"]) : [];
}
else if( is_array( $festivity["common"] ) ) {
$this->common = LitCommon::areValid(explode(",", $festivity["common"])) ? explode(",", $festivity["common"]) : [];
} elseif (is_array($festivity["common"])) {
//Festivity::debugWrite( "*** Festivity.php *** common vartype is array, value = " . implode( ', ', $festivity["common"] ) );
if( LitCommon::areValid( $festivity["common"] ) ) {
if (LitCommon::areValid($festivity["common"])) {
$this->common = $festivity["common"];
} else {
//Festivity::debugWrite( "*** Festivity.php *** common values have not passed the validity test!" );
Expand Down
15 changes: 8 additions & 7 deletions includes/LitCalFeedItem.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
include_once( 'includes/Festivity.php' );

class LitCalFeedItem {
include_once('includes/Festivity.php');

class LitCalFeedItem
{
public string $uid;
public string $titleText;
public string $mainText;
public string $redirectionUrl;
public string $updateDate;

public function __construct( string $key, Festivity $festivity, DateTime $publishDate, string $titleText, string $mainText ) {
$this->uid = "urn:uuid:" . md5( "LITCAL-" . $key . '-' . $festivity->date->format( 'Y' ) );
$this->updateDate = $publishDate->format( "Y-m-d\TH:i:s\Z" );
public function __construct(string $key, Festivity $festivity, DateTime $publishDate, string $titleText, string $mainText)
{
$this->uid = "urn:uuid:" . md5("LITCAL-" . $key . '-' . $festivity->date->format('Y'));
$this->updateDate = $publishDate->format("Y-m-d\TH:i:s\Z");
$this->titleText = $titleText;
$this->mainText = $mainText;
$this->redirectionUrl = "https://litcal.johnromanodorazio.com/";
}

}
}
Loading

0 comments on commit 3fed7bf

Please sign in to comment.