private function assertValidCampaign(array $campaign)
    {
        if (!isset($campaign['subject'])) {
            throw new InvalidArgumentException('subject field should be set');
        }

        if (!isset($campaign['from'])) {
            throw new InvalidArgumentException('from field should be set');
        }

        if (!isset($campaign['message_type'])
            || !in_array($campaign['message_type'], ['email', 'text_message'])) {
            throw new InvalidArgumentException('Appropriate message_type should be set');
        }

        if (!isset($campaign['recipients'])) {
            throw new InvalidArgumentException('Recipients should be set');
        }

        if (!isset($campaign['content'])) {
            throw new InvalidArgumentException('Content should be set');
        }
    }
private function assertValidCampaign(array $campaign)
    {
        if (!isset($campaign['subject'])) {
            throw new InvalidArgumentException('subject field should be set');
        }

        if (!isset($campaign['from'])) {
            throw new InvalidArgumentException('from field should be set');
        }

        if (!isset($campaign['message_type'])
            || !in_array($campaign['message_type'], ['email', 'text_message'])) {
            throw new InvalidArgumentException('Appropriate message_type should be set');
        }

        if (!isset($campaign['recipients'])) {
            throw new InvalidArgumentException('Recipients should be set');
        }

        if (!isset($campaign['content'])) {
            throw new InvalidArgumentException('Content should be set');
        }
    }
private function assertValidCampaign ( array $ campaign ) { if ( ! isset ( $ campaign [ 'subject' ] ) ) { throw new InvalidArgumentException ( 'subject field should be set' ) ; } if ( ! isset ( $ campaign [ 'from' ] ) ) { throw new InvalidArgumentException ( 'from field should be set' ) ; } if ( ! isset ( $ campaign [ 'message_type' ] ) || ! in_array ( $ campaign [ 'message_type' ] , [ 'email' , 'text_message' ] ) ) { throw new InvalidArgumentException ( 'Appropriate message_type should be set' ) ; } if ( ! isset ( $ campaign [ 'recipients' ] ) ) { throw new InvalidArgumentException ( 'Recipients should be set' ) ; } if ( ! isset ( $ campaign [ 'content' ] ) ) { throw new InvalidArgumentException ( 'Content should be set' ) ; } }
Check if campaign is correctly formated

@param array $campaign Campaign to validate
@throws InvalidArgumentException
Check if campaign is correctly formated