Skip to content

Commit

Permalink
Develop (#8)
Browse files Browse the repository at this point in the history
* Added more test coverage.

* Added StyleCI

* Fixed the Style

* Refactored code and unit test.

* Remove globals.

* Minor refactor

* Minor refactor

* Minor refactor

* Updated the PHPdocs

* Changed the comment positioning

* Update .scrutinizer.yml

* Update .scrutinizer.yml

* Removed scruitnizer and StyleCI

* Added documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* updated the documentation

* Update Collection.md

* Update Collection.md

* Create ArrayHelper.md

* Update Collection.md

* Update index.md

* Added Encrypter documentation.

* Update composer.json

* Documentation for StringHelper

* Documentation for StringHelper

* Updated the Collection.

* Minor composer.json refactor.

* Refactored the test.

* Refactored the test and added more docs.

* Added more docs

* Added Mailgun transport and rest of the docs.

* Fixed the link.

* Fixed the link.

* Merged master.

* Merged master.
  • Loading branch information
nicholasnet authored Dec 5, 2016
1 parent 2570192 commit ebdbe8d
Show file tree
Hide file tree
Showing 18 changed files with 742 additions and 61 deletions.
137 changes: 137 additions & 0 deletions docs/Swiftmailer/Transports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# SwiftMailer Transports
Back to [index](../index.md)

- [Introduction](#introduction)
- [Setup](#setup)
- [Available Transport](#available-transport)

<a name="introduction"></a>
## Introduction
Mailer transport allows user to use send email in different.

**Please Note: This package contains SwifMailer transport it does not mean you will need to install SwiftMailer. You only need to install it if you want to use it.**

_Almost all transports except MailTrapper transports are the ported from Laravel Framework you can find more information [here](https://laravel.com/docs/5.3/mail#introduction)._

<a name="available-transport"></a>
## Available transports
- [MailTrap](#mailtrap)
- [Mailgun](#mailgun)
- [Mandrill](#mandrill)
- [AWS SES](#ses)
- [Sparkpost](#spark)

<a name="mailtrap"></a>
### MailTrap
Setup and usage

$transport = (new \IdeasBucket\Common\Swiftmailer\Transport\Mailtrap)
->setUsername('your username')
->setPassword('your password');
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);

<a name="mailgun"></a>
### Mailgun

*Requires Guzzle which can be installed using composer*

composer require guzzlehttp/guzzle

Setup and usage

$transport = (new \IdeasBucket\Common\Swiftmailer\Transport\Mailgun(new GuzzleHttp\Client, 'YOUR API KEY', 'YOUR DOMAIN));
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);
<a name="mandrill"></a>
### Mandrill

*Requires Guzzle which can be installed using composer*

composer require guzzlehttp/guzzle

Setup and usage

$transport = (new \IdeasBucket\Common\Swiftmailer\Transport\Mandrill(new GuzzleHttp\Client, 'YOUR API KEY'));
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);
<a name="ses"></a>
### AWS SES

*To use the Amazon SES driver you must first install the Amazon AWS SDK for PHP. You may install this library by adding the following line to your `composer.json` file's `require` section and running the `composer update` command:*

"aws/aws-sdk-php": "~3.0"

Setup and usage

use Aws\Ses\SesClient;

$client = SesClient::factory([
'profile' => '<profile in your aws credentials file>',
'region' => '<region name>'
]);

$transport = (new \IdeasBucket\Common\Swiftmailer\Transport\Ses($client);
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);
<a name="sparkpost"></a>
### SparkPost

*Requires Guzzle which can be installed using composer*

composer require guzzlehttp/guzzle

Setup and usage

$transport = (new \IdeasBucket\Common\Swiftmailer\Transport\SparkPost(new GuzzleHttp\Client, 'YOUR API KEY'));
$mailer = Swift_Mailer::newInstance($transport);

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => 'A name'))
->setBody('Here is the message itself');

// Send the message
$result = $mailer->send($message);

56 changes: 56 additions & 0 deletions docs/Twig/Extension.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Extension
Back to [index](../index.md)

- [Introduction](#introduction)
- [Setup](#setup)
- [Available Filters](#available-filters)

<a name="introduction"></a>
## Introduction
This Twig extension provides several filters that can be used in Twig template.

**Please Note: This package contains Twig extension it does not mean you will need to install Twig. You only need to install it if you want to use it.**

<a name="setup"></a>
## Setup
$twig = new Twig_Environment($loader);
$twig->addExtension(new \IdeasBucket\Common\Twig\Extension);

<a name="available-filters"></a>
## Available Filters
- [bin2hex](#bin2hex)
- [slug](#slug)
- [md5](#md5)

<a name="bin2hex"></a>
### bin2hex
Returns an ASCII string containing the hexadecimal representation of str. The conversion is done byte-wise with the high-nibble first.

Usage {{ test|bin2hex }}

// Outputs
74657374

<a name="slug"></a>
### slug
Returns normalized version of string that can be use as index that is easy to remember. Requires **php_intl** extension.

Usage {{ Hello World|slug }}

// Outputs - By default uses - as separator and converts to lower case.
hello-world

Usage {{ Hello World|slug(false, '_') }}

// Outputs - Using different separator and no string coversion
Hello_World

<a name="md5"></a>
### md5
Returns md5 hash of a input

Usage {{ Hello World|md5 }}

// Outputs
b10a8db164e0754105b7a99be72e3fe5

91 changes: 91 additions & 0 deletions docs/Utils/ArrayToXml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ArrayToXml
Back to [index](../index.md)

- [Introduction](#introduction)
- [Available Methods](#available-methods)

<a name="introduction"></a>
## Introduction
#### This class is inspired by work of [Lalit Lab](http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/)
The `IdeasBucket\Common\Utils\ArrayToXml` class provides method that can convert array into XML.

<a name="available-methods"></a>
## Available Methods
* [createXml](#create-xml)
* [getXmlString](#get-xml-string)

<a name="create-xml"></a>
#### `createXml()`
The `createXml` method coverts the given Array to DOMDocument.

$nest = ['type' => 'test', 'nest' => [
'nest' => [
'nest' => [
'@attributes' => [
'prop1' => 'aloha',
'prop2' => 'hello',
'prop3' => 'ke cha',
],
'nest' => [
'@attributes' => [
'prop1' => 'bazingaaa!!!!',
],
],
],
],
]];

ArrayToXml::createXml('test', $nest); // Will return \DOMDocument
OR
ArrayToXml::createXml('test', $nest, 'UTF-8') // Will return \DOMDocument

// Will produce \DOMDocument instace with following content.
// <?xml version="1.0" encoding="UTF-8"?>
// <test>
// <type>test</type>
// <nest>
// <nest>
// <nest prop1="aloha" prop2="hello" prop3="ke cha">
// <nest prop1="bazingaaa!!!!"/>
// </nest>
// </nest>
// </nest>
// </test>

<a name="get-xml-string"></a>
#### `getXmlString()`
The `getXmlString` method coverts the given Array to string.

$nest = ['type' => 'test', 'nest' => [
'nest' => [
'nest' => [
'@attributes' => [
'prop1' => 'aloha',
'prop2' => 'hello',
'prop3' => 'ke cha',
],
'nest' => [
'@attributes' => [
'prop1' => 'bazingaaa!!!!',
],
],
],
],
]];

ArrayToXml::getXmlString'test', $nest); // Will return string
OR
ArrayToXml::getXmlString('test', $nest, 'UTF-8') // Will return string

// Will produce string instace with following content.
// <?xml version="1.0" encoding="UTF-8"?>
// <test>
// <type>test</type>
// <nest>
// <nest>
// <nest prop1="aloha" prop2="hello" prop3="ke cha">
// <nest prop1="bazingaaa!!!!"/>
// </nest>
// </nest>
// </nest>
// </test>
6 changes: 4 additions & 2 deletions docs/Utils/StringHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Back to [index](../index.md)

<a name="introduction"></a>
## Introduction
#### This class is inspired by Laravel, CakePHP3 and YII2 frameworks. You can find more information about YII2 here and Laravel here.
#### This class is inspired by Laravel, CakePHP 3 and YII2 frameworks.

<a name="available-methods"></a>
## Available Methods
Expand Down Expand Up @@ -105,7 +105,9 @@ The `startsWith` function determines if the given string begins with the given v
<a name="method-starts-with"></a>
#### `uuid()`

The `uuid` generate unique identifiers as per **RFC 4122**. The UUID is a 128-bit string in the format of 485fc381-e790-47a3-9794-1337c0a8fe68:
The `uuid` generate unique identifiers as per **RFC 4122**. The UUID is a 128-bit string in the format of 485fc381-e790-47a3-9794-1337c0a8fe68:

**_This method should not be used as a random seed for any cryptographic operations._**

$value = StringHelper::uuid();

54 changes: 54 additions & 0 deletions docs/Utils/XmlToArray.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# XmlToArray
Back to [index](../index.md)

- [Introduction](#introduction)
- [Available Methods](#available-methods)

<a name="introduction"></a>
## Introduction
#### This class is inspired by work of [Lalit Lab](http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/)
The `IdeasBucket\Common\Utils\XmlToArray` class provides method that can convert XML into plain PHP array.

<a name="available-methods"></a>
## Available Methods
* [createArray](#create-array)

<a name="create-array"></a>
#### `createArray()`
The `createArray` method coverts the given XML to Array.

XmlToArray::createArray('<a version="1.0"><b><c><f name="test">ererf</f></c></b></a>');

// Will produce array like this.
// Array
// (
// [a] => Array
// (
// [b] => Array
// (
// [c] => Array
// (
// [f] => Array
// (
// [@value] => ererf
// [@attributes] => Array
// (
// [name] => test
// )
//
// )
//
// )
//
// )
//
// [@attributes] => Array
// (
// [version] => 1.0
// )
//
// )
//
// )


9 changes: 6 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Documentation
* Utils
* [ArrayHelper](Utils/ArrayHelper.md)
* ArrayToXml
* [ArrayToXml](Utils/ArrayToXml.md)
* [Collection](Utils/Collection.md)
* [Encrypter](Utils/Encrypter.md)
* [StringHelper](Utils/StringHelper.md)
* XmlToArray

* [XmlToArray](Utils/XmlToArray.md)
* Twig
* [Extension](Utils/Extension.md)
* SwiftMailer
* [Transports](Swiftmailer/Transports.md)
Loading

0 comments on commit ebdbe8d

Please sign in to comment.