# \Producers_MixpanelBaseProducer

Provides some base methods for use by a message Producer

## Summary

Methods
Properties
Constants
__construct()
__destruct()
flush()
reset()
getQueue()
getToken()
enqueue()
enqueueAll()
_getEndpoint()
No public properties found
No constants found
_log()
_debug()
_getConsumer()
_persist()
$_options
$_token
$_max_queue_size
N/A
No private methods found
$_defaults
$_queue
$_consumer
$_consumers
N/A
abstract

File
  Producers/MixpanelBaseProducer.php
Package
  Default
Class hierarchy
  \Base_MixpanelBase
  \Producers_MixpanelBaseProducer

## Tags

None found

## Properties

### $_options

    $_options : array

An array of options to be used by the Mixpanel library.

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### $_token

    $_token : string

#### Type

string — a token associated to a Mixpanel project

#

## Tags

None found

### $_max_queue_size

    $_max_queue_size : integer

If the queue reaches this size we'll auto-flush to prevent out of memory errors

#### Type

integer

#

## Tags

None found

### $_defaults

    $_defaults : array

Default options that can be overridden via the $options constructor arg

#### Type

array

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### $_queue

    $_queue : array

#### Type

array — a queue to hold messages in memory before flushing in batches

#

## Tags

None found

### $_consumer

    $_consumer : \ConsumerStrategies_AbstractConsumer

#### Type

\ConsumerStrategies_AbstractConsumer — the consumer to use when flushing messages

#

## Tags

None found

### $_consumers

    $_consumers : array

#### Type

array — The list of available consumers

#

## Tags

None found

## Methods

### __construct()

    __construct(  $token, array  $options = array())

Creates a new MixpanelBaseProducer, assings Mixpanel project token, registers custom Consumers, and instantiates the desired consumer

#### Parameters

| $token |
array | $options |

#

## Tags

None found

### __destruct()

    __destruct()

Flush the queue when we destruct the client with retries

#

## Tags

None found

### flush()

    flush(integer  $desired_batch_size = 50) : boolean

Iterate the queue and write in batches using the instantiated Consumer Strategy

#### Parameters

integer | $desired_batch_size |

#### Returns

boolean —

whether or not the flush was successful

#

## Tags

None found

### reset()

    reset()

Empties the queue without persisting any of the messages

#

## Tags

None found

### getQueue()

    getQueue() : array

Returns the in-memory queue

#### Returns

array

#

## Tags

None found

### getToken()

    getToken() : string

Returns the current Mixpanel project token

#### Returns

string

#

## Tags

None found

### enqueue()

    enqueue(array  $message = array())

Add an array representing a message to be sent to Mixpanel to a queue.

#### Parameters

array | $message |

#

## Tags

None found

### enqueueAll()

    enqueueAll(array  $messages = array())

Add an array representing a list of messages to be sent to Mixpanel to a queue.

#### Parameters

array | $messages |

#

## Tags

None found

### _getEndpoint()

    _getEndpoint() : string

Return the endpoint that should be used by a consumer that consumes messages produced by this producer.

#### Returns

string

#

abstract

## Tags

None found

### _log()

    _log(  $msg)

Log a message to PHP's error log

#### Parameters

| $msg |

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### _debug()

    _debug() : boolean

Returns true if in debug mode, false if in production mode

#### Returns

boolean

#

Inherited from
  \Base_MixpanelBase

## Tags

None found

### _getConsumer()

    _getConsumer() : \ConsumerStrategies_AbstractConsumer

Given a strategy type, return a new PersistenceStrategy object

#### Returns

\ConsumerStrategies_AbstractConsumer

#

## Tags

None found

### _persist()

    _persist(  $message) : mixed

Given an array of messages, persist it with the instantiated Persistence Strategy

#### Parameters

| $message |

#### Returns

mixed

#

## Tags

None found

### MixpanelBaseProducer.php