Skip to content

Commit

Permalink
Allow modification of PlaylistEntry properties only through setter
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Oct 10, 2024
1 parent 63cb557 commit c8ea42b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions engine/PlaylistEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
* (Note that spin properties (e.g., getArtist, getTrack()) are implemented
* via introspection, so you will not see them declared here, though they are
* available for use.)
*
* In addition, the event may be inspected by means of read-only properties
* on the object; e.g., $entry->type, $entry->artist, $entry->comment.
*/
class PlaylistEntry {
const TYPE_SPIN = 0;
Expand Down Expand Up @@ -96,11 +99,7 @@ public function __get($name) {
}

public function __set($name, $value) {
// disallow setting of synthetic properties
if(method_exists($this, "get" . ucfirst($name)))
return;

$this->entry[$name] = $value;
throw new \Error("Property is immutable; use setter to modify event");
}

public static function scrubField($field, $length = PlaylistEntry::MAX_FIELD_LENGTH) {
Expand Down

0 comments on commit c8ea42b

Please sign in to comment.