Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
vaidas-lungis committed Dec 8, 2015
0 parents commit 58cefb4
Show file tree
Hide file tree
Showing 7 changed files with 438 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
### Composer template
composer.phar
vendor/

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock


## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### Linux template
*~

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*
### Windows template
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
### OSX template
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Created by .ignore support plugin (hsz.mobi)
11 changes: 11 additions & 0 deletions Contract/Formatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php


namespace Mailer\Contract;


interface Formatable
{
public function setFormatter(MessageFormatter $formatter);
public function getFormatted(Messageable $message);
}
19 changes: 19 additions & 0 deletions Contract/MessageFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace Mailer\Contract;


interface MessageFormatter
{
/**
* @param Messageable $message
* @return void
*/
public function setMessage(Messageable $message);

/**
* @return string
*/
public function format();
}
43 changes: 43 additions & 0 deletions Contract/Messageable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php


namespace Mailer\Contract;

interface Messageable
{
/**
* @return int
*/
public function getClientId();

/**
* @return string
*/
public function getEmail();

/**
* @return string
*/
public function getFirstName();

/**
* @return string
*/
public function getLastName();

public function setLang($lang = 'en');

/**
* @return mixed
*/
public function getLang();

/**
* @return mixed
*/
public function getEvent();


public function setExtras(array $extras);
public function getExtras();
}
55 changes: 55 additions & 0 deletions Formatters/Events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php


namespace Mailer\Formatters;

use Mailer\Contract\Messageable;
use Mailer\Contract\MessageFormatter;

class Events implements MessageFormatter
{
/**
* @var Messageable
*/
private $message = null;
private $source = '';

/**
* @param Messageable $message
*/
public function setMessage(Messageable $message)
{
$this->message = $message;
}

public function setSource($name)
{
$this->source = $name;
}
public function getSource()
{
return !empty($this->source) ? $this->source : gethostname();
}


/**
* @return string
*/
public function format()
{
$out = array(
'brand' => $this->getSource(),
'event_name' => $this->message->getEvent(),
'to' => array(
'client_id' => $this->message->getClientId(),
'email' => $this->message->getEmail(),
'first_name' => $this->message->getFirstName(),
'last_name' => $this->message->getLastName(),
'lang' => $this->message->getLang(),
),
'vars' => $this->message->getExtras(),
);
return json_encode($out);
}

}
Loading

0 comments on commit 58cefb4

Please sign in to comment.