Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
greta-mik committed Jul 3, 2024
1 parent dbc362d commit d56c0d3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions omnisend/includes/SDK/V1/class-event.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Omnisend Client
*
Expand All @@ -19,6 +20,7 @@
class Event {



private $contact = null;
private $event_name = null;
private $event_time = null;
Expand All @@ -36,34 +38,34 @@ class Event {
public function validate(): WP_Error {

$error = new WP_Error();
if ( $contact instanceof Contact ) {
$error->merge_from( $contact->validate() );
if ( $this->contact instanceof Contact ) {
$error->merge_from( $this->contact->validate() );
}

if ( $this->$event_name == null ) {
if ( $this->event_name == null ) {
$error->add( 'event_name', 'Is required.' );
}

if ( $this->$event_name != null && ! is_string( $this->$event_name ) ) {
$error->add( $event_name, 'Not a string.' );
if ( $this->event_name != null && ! is_string( $this->event_name ) ) {
$error->add( 'event_name', 'Not a string.' );
}

if ( $this->$event_version != null && ! is_string( $this->$event_version ) ) {
$error->add( $event_version, 'Not a string.' );
if ( $this->event_version != null && ! is_string( $this->event_version ) ) {
$error->add( 'event_version', 'Not a string.' );
}

if ( $this->$origin != null && ! is_string( $this->$origin ) ) {
$error->add( $origin, 'Not a string.' );
if ( $this->origin != null && ! is_string( $this->origin ) ) {
$error->add( 'origin', 'Not a string.' );
}

if ( $this->$event_time != null ) {
$dt = DateTime::createFromFormat( 'Y-m-d', $event_time );
if ( $this->event_time != null ) {
$dt = DateTime::createFromFormat( 'Y-m-d', $this->event_time );
if ( ! $dt ) {
$error->add( $event_time, 'Not valid date format.' );
$error->add( 'event_time', 'Not valid date format.' );
}
}

foreach ( $properties as $name => $value ) {
foreach ( $this->properties as $name => $value ) {
if ( ! is_string( $name ) ) {
$error->add( $name, 'Not a string.' );
}
Expand Down

0 comments on commit d56c0d3

Please sign in to comment.