Skip to content

Commit

Permalink
Init repository
Browse files Browse the repository at this point in the history
  • Loading branch information
merlin committed Jun 26, 2015
0 parents commit 405c169
Show file tree
Hide file tree
Showing 15 changed files with 478 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: test/clover.xml
json_path: coveralls-upload.json
src_dir: src
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/test export-ignore
/vendor export-ignore
.coveralls.yml export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.php_cs export-ignore
phpunit.xml.dist export-ignore
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.buildpath
.DS_Store
.idea
.project
.settings/
.*.sw*
.*.un~
nbproject
tmp/

clover.xml
composer.lock
coveralls-upload.json
phpunit.xml
vendor
45 changes: 45 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->in('src')
->in('test')
->notPath('TestAsset')
->notPath('_files')
->filter(function (SplFileInfo $file) {
if (strstr($file->getPath(), 'compatibility')) {
return false;
}
});
$config = Symfony\CS\Config\Config::create();
$config->level(null);
$config->fixers(
array(
'braces',
'duplicate_semicolon',
'elseif',
'empty_return',
'encoding',
'eof_ending',
'function_call_space',
'function_declaration',
'indentation',
'join_function',
'line_after_namespace',
'linefeed',
'lowercase_keywords',
'parenthesis',
'multiple_use',
'method_argument_space',
'object_operator',
'php_closing_tag',
'remove_lines_between_uses',
'short_array_syntax',
'short_tag',
'standardize_not_equal',
'trailing_spaces',
'unused_use',
'visibility',
'whitespacy_lines',
)
);
$config->finder($finder);
return $config;
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
sudo: false

language: php

branches:
except:
- /^release-.*$/
- /^ghgfk-.*$/

cache:
directories:
- $HOME/.composer/cache

matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- php: 7
- php: hhvm
allow_failures:
- php: 7
- php: hhvm

notifications:
slack: eoko:xD7FhK32T6o2xDti5TCXOYps

before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs

script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
21 changes: 21 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Eoko\Mandrill;

class Module
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src',
],
],
];
}
}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Zf-Mandrill

[![Build Status](https://travis-ci.org/eoko/zf-mandrill.svg?branch=master)](https://travis-ci.org/eoko/zf-mandrill)
[![Coverage Status](https://coveralls.io/repos/eoko/zf-mandrill/badge.svg)](https://coveralls.io/r/eoko/zf-mandrill)


## Command

#### Validate Key



```PHP

// -v or --verbose will display the current key
php public/index.php mandrill check -v

```
55 changes: 55 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "eoko/console",
"description": " ",
"license": "BSD-3-Clause",
"keywords": [
"eoko",
"zf2",
"mandrill"
],

"homepage": "https://github.com/eoko/zf-mandrill",

"autoload": {
"psr-4": {
"Eoko\\Console\\": "src/"
}
},

"require": {
"php": ">=5.5",
"zendframework/zend-stdlib": "~2.5",
"zendframework/zend-console": "~2.5",
"zendframework/zend-servicemanager": "~2.5",
"mandrill/mandrill": "dev-master"
},

"minimum-stability": "dev",

"prefer-stable": true,

"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},

"autoload-dev": {
"psr-4": {
"ZendTest\\Console\\": "test/"
}
},

"require-dev": {
"satooshi/php-coveralls": "^0.7.0@dev",
"mockery/mockery": "^1.0@dev",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0",
"zendframework/zend-filter": "~2.5",
"zendframework/zend-json": "~2.5",
"zendframework/zend-validator": "~2.5",
"phpunit/phpunit": "^5.0@dev",
"zendframework/zend-servicemanager": "^2.5@dev"
}
}
34 changes: 34 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

return [
'service_manager' => [
'factories' => [
'eoko.mandrill.client' => 'Eoko\Mandrill\Client\MandrillFactory',
],
],


'controllers' => [
'factories' => [
'Eoko\Mandrill\Controller\Index' => 'Eoko\Mandrill\Controller\IndexControllerFactory'
],
],


// Placeholder for console routes
'console' => [
'router' => [
'routes' => [
'b' => [
'options' => [
'route' => 'mandrill check [--verbose|-v]',
'defaults' => [
'controller' => 'Eoko\Mandrill\Controller\Index',
'action' => 'keyValidation',
],
],
]
],
],
],
];
9 changes: 9 additions & 0 deletions config/module.config.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'eoko' => [
'mandrill' => [
'apiKey' => 's3cret'
],
],
];
38 changes: 38 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./test/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="eoko-zf-mandrill">
<directory>./test/</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<php>
<ini name="date.timezone" value="UTC"/>

<!-- OB_ENABLED should be enabled for some tests to check if all
functionality works as expected. Such tests include those for
Zend\Soap and Zend\Session, which require that headers not be sent
in order to work. -->
<env name="TESTS_ZEND_OB_ENABLED" value="false" />

<!-- Note: the following is a FULL list of ALL POSSIBLE constants
currently in use in ZF2 for ALL COMPONENTS; you should choose the
constants appropriate to the component you are migrating. -->

</php>
</phpunit>
31 changes: 31 additions & 0 deletions src/Client/MandrillFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: merlin
* Date: 16/06/15
* Time: 21:45
*/

namespace Eoko\Mandrill\Client;

use Mandrill;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class MandrillFactory implements FactoryInterface
{

/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('configuration');
$key = (isset($config['eoko']['mandrill']['apiKey'])) ? $config['eoko']['mandrill']['apiKey'] : null;

return new Mandrill($key);
}
}
45 changes: 45 additions & 0 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Eoko\Mandrill\Controller;

use Eoko\Console\Helper\MessageHelper;
use Exception;
use Mandrill;
use Mandrill_Invalid_Key;
use Zend\Console\Prompt\Line;
use Zend\Mvc\Controller\AbstractConsoleController;

class IndexController extends AbstractConsoleController
{
/** @var Mandrill */
protected $client;

/** @var string */
protected $verbose;

public function __construct($client, $verbose = '')
{
MessageHelper::$verbosity = $verbose;
$this->verbose = $verbose;
$this->client = $client;
}

public function keyValidationAction()
{
while (1) {
try {
$this->client->users->ping();
$this->message()->show('[success]The mandrill Api Key is valid[/success].' . "\n" . '[v][danger]Your key is {{key}}[/danger][/v]',
['key' => $this->client->apikey]
);
break;
} catch (Mandrill_Invalid_Key $e) {
$this->message()->show('[danger]Mandrill is not properly configured[/danger]');
$this->client->apikey = (new Line("Please enter another API key (press ENTER to quit) : "))->show();
} catch (Exception $e) {
$this->message()->show('[danger]{{message}}[/danger]', ['message' => $e->getMessage()]);
break;
}
}
}
}
Loading

0 comments on commit 405c169

Please sign in to comment.