Skip to content

Commit

Permalink
comment out unused AB method
Browse files Browse the repository at this point in the history
make sure all LitCommon methods allow for arrays
  • Loading branch information
JohnRDOrazio committed May 19, 2022
1 parent 293c469 commit 5450010
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion includes/Festivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function __construct(string $name, DateTime $date, string|array $color = '???',
$this->grade = $grade >= LitGrade::WEEKDAY && $grade <= LitGrade::HIGHER_SOLEMNITY ? $grade : -1;
$this->displayGrade = $displayGrade;
if( is_string( $common ) ) {
$this->common = strpos( $common, "," ) && LitCommon::areValid( explode(",", $common) ) ? explode(",", $common) : ( LitCommon::isValid( $common ) ? [ $common ] : [ '???' ] );
$this->common = LitCommon::areValid( explode(",", $common) ) ? explode(",", $common) : [ '???' ];
}
else if( is_array( $common ) && LitCommon::areValid( $common ) ) {
$this->common = $common;
Expand Down
28 changes: 20 additions & 8 deletions includes/enums/LitCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public static function areValid( array $values ) {
return empty( array_diff( $values, self::$values ) );
}

/*
public static function AB( string|array $value ) : string {
if( is_array( $value ) ) {
$mapped = array_map('self::AB', $value);
Expand All @@ -291,9 +292,13 @@ public static function AB( string|array $value ) : string {
}
}
}
*/

public function i18n( string $value ) : string {
if( self::isValid( $value ) ) {
public function i18n( string|array $value ) : string|array {
if( is_array( $value ) && self::areValid( $value ) ) {
return array_map( [$this, 'i18n'], $value );
}
else if( self::isValid( $value ) ) {
if( $this->locale === LitLocale::LATIN ) {
return self::LATIN[ $value ];
} else{
Expand All @@ -303,20 +308,27 @@ public function i18n( string $value ) : string {
return $value;
}

public function getPossessive( string $value ) : string {
public function getPossessive( string|array $value ) : string|array {
if( is_array( $value ) ) {
return array_map( [$this, 'getPossessive'], $value );
}
return $this->locale === LitLocale::LATIN ? "" : self::POSSESSIVE( $value );
}

/**
* Function C
* Returns a translated human readable string of the Common or the Proper
*/
public function C( string $common="" ) : string {
if ($common !== "") {
if( $common === LitCommon::PROPRIO ) {
public function C( string|array $common="" ) : string|array {
if ( ( is_string( $common ) && $common !== "" ) || is_array( $common ) ) {
if( (is_string( $common ) && $common === LitCommon::PROPRIO) || ( is_array( $common ) && in_array( LitCommon::PROPRIO, $common ) ) ) {
$common = $this->i18n( $common );
} else{
$commons = explode(",", $common);
} else {
if( is_string( $common ) ) {
$commons = explode(",", $common);
} else {
$commons = $common;
}
$commons = array_map(function ($txt) {
if( strpos($txt, ":") !== false ){
[$commonGeneral, $commonSpecific] = explode(":", $txt);
Expand Down

0 comments on commit 5450010

Please sign in to comment.