Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rdrenth committed Jul 22, 2016
2 parents cb0d603 + 00f41d6 commit d3e2615
Show file tree
Hide file tree
Showing 14 changed files with 2,996 additions and 54 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
phpunit.xml
vendor/
composer.lock
.idea/*
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.1.0
* Update code style
* Update composer requirements
* Fix broken link in README
* Add filter `lcfirst`
* Add filter `ucfirst`

## 1.0.3
* Update minimal PHP requirement to 5.3.3
* Update composer autoload settings
Expand All @@ -13,4 +20,4 @@
* Add badges to README

## 1.0.0
* Initial version of the `rdrenth/twig-extension-bundle` bundle.
* Initial version of the `rdrenth/twig-extension-bundle` bundle.
9 changes: 7 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
* @throws \RuntimeException
*/
public function getConfigTreeBuilder()
{
Expand All @@ -31,6 +32,7 @@ public function getConfigTreeBuilder()

/**
* @param ArrayNodeDefinition $rootNode
* @throws \RuntimeException
*/
private function addStringySection(ArrayNodeDefinition $rootNode)
{
Expand All @@ -52,6 +54,8 @@ private function addStringySection(ArrayNodeDefinition $rootNode)
->append($this->addStringyMethodNode('slugify'))
->append($this->addStringyMethodNode('titleize'))
->append($this->addStringyMethodNode('underscored'))
->append($this->addStringyMethodNode('lcfirst', 'lowerCaseFirst'))
->append($this->addStringyMethodNode('ucfirst', 'upperCaseFirst'))
->end()
->end()
->arrayNode('extra_filters')
Expand All @@ -60,7 +64,7 @@ private function addStringySection(ArrayNodeDefinition $rootNode)
->scalarNode('filter')->end()
->scalarNode('method')
->validate()
->ifTrue(function($value) { return !method_exists('Stringy\Stringy', $value); })
->ifTrue(function ($value) { return !method_exists('Stringy\Stringy', $value); })
->thenInvalid('Method %s does not on the class Stringy\Stringy.')
->end()
->end()
Expand All @@ -76,6 +80,7 @@ private function addStringySection(ArrayNodeDefinition $rootNode)
* @param string $filterName
* @param string|null $methodName
* @return NodeDefinition
* @throws \RuntimeException
*/
private function addStringyMethodNode($filterName, $methodName = null)
{
Expand All @@ -90,7 +95,7 @@ private function addStringyMethodNode($filterName, $methodName = null)
->scalarNode('method')
->defaultValue($methodName ?: $filterName)
->validate()
->ifTrue(function($value) { return !method_exists('Stringy\Stringy', $value); })
->ifTrue(function ($value) { return !method_exists('Stringy\Stringy', $value); })
->thenInvalid('Method %s does not on the class Stringy\Stringy.')
->end()
->end()
Expand Down
7 changes: 5 additions & 2 deletions DependencyInjection/RdrenthTwigExtensionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* RdrenthTwigExtensionExtension
* Class RdrenthTwigExtensionExtension
*
* @author Ronald Drenth <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
Expand All @@ -18,6 +19,7 @@ class RdrenthTwigExtensionExtension extends Extension
{
/**
* {@inheritdoc}
* @throws \Exception
*/
public function load(array $config, ContainerBuilder $container)
{
Expand All @@ -27,7 +29,7 @@ public function load(array $config, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');

if (isset($config['stringy'])) {
if (array_key_exists('stringy', $config)) {
$this->registerStringyConfiguration($config['stringy'], $container, $loader);
}
}
Expand All @@ -44,6 +46,7 @@ public function getAlias()
* @param array $config
* @param ContainerBuilder $container
* @param XmlFileLoader $loader
* @throws InvalidArgumentException
*/
private function registerStringyConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For more information about each filter, please check the links.
{{ 'fooBar'|dasherize }} {# foo-bar #}
```

#### [delimit](https://github.com/danielstjules/Stringy#delimit)
#### [delimit](https://github.com/danielstjules/Stringy#delimitint-delimiter)

```twig
{{ 'fooBar'|delimit('::') }} {# foo::bar #}
Expand Down Expand Up @@ -61,6 +61,18 @@ For more information about each filter, please check the links.
{{ 'TestUCase'|underscored }} {# test_u_case #}
```

#### [lcfirst](https://github.com/danielstjules/Stringy#lowercasefirst)

```twig
{{ 'LowerCaseFirst'|lcfirst }} {# lowerCaseFirst #}
```

#### [ucfirst](https://github.com/danielstjules/Stringy#uppercasefirst)

```twig
{{ 'upperCaseFirst'|ucfirst }} {# UpperCaseFirst #}
```


## Installation
### Step 1: Install RdrenthTwigExtensionBundle using [Composer](http://getcomposer.org)
Expand Down
2 changes: 1 addition & 1 deletion RdrenthTwigExtensionBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* RdrenthTwigExtensionBundle
* Class RdrenthTwigExtensionBundle
*
* @author Ronald Drenth <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
Expand Down
2 changes: 1 addition & 1 deletion Resources/meta/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Ronald Drenth <[email protected]>
Copyright (c) 2016 Ronald Drenth <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 11 additions & 11 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Symfony\Component\Yaml\Yaml;

/**
* ConfigurationTest
* Class ConfigurationTest
*
* @author Ronald Drenth <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @link https://github.com/rdrenth/twig-extension-bundle
*/
class ConfigurationTest extends \PHPUnit_Framework_TestCase
final class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
/**
* @return array
Expand All @@ -40,7 +40,7 @@ public function testDefaultConfigurationProcessing()
$rawConfig = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/default.yml'));
$config = $this->processConfiguration($rawConfig);

$this->assertArrayHasKey('stringy', $config);
self::assertArrayHasKey('stringy', $config);
}

/**
Expand All @@ -51,13 +51,13 @@ public function testStringyConfigurationProcessing()
$rawConfig = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/stringy.yml'));
$config = $this->processConfiguration($rawConfig);

$this->assertArrayHasKey('stringy', $config);
self::assertArrayHasKey('stringy', $config);
$config = $config['stringy'];

$this->assertArrayHasKey('enabled', $config);
$this->assertArrayHasKey('encoding', $config);
$this->assertArrayHasKey('filters', $config);
$this->assertArrayHasKey('extra_filters', $config);
self::assertArrayHasKey('enabled', $config);
self::assertArrayHasKey('encoding', $config);
self::assertArrayHasKey('filters', $config);
self::assertArrayHasKey('extra_filters', $config);

$filters = $config['filters'];
foreach ($this->provideStringyFilters() as $filterName => $methodName) {
Expand Down Expand Up @@ -86,11 +86,11 @@ public function testInvalidStringyMethod()
private function assertStringyFilter(array $filters, $indexName, $filterName, $methodName, $enabled = null)
{
if ($enabled !== null) {
$this->assertEquals($enabled, $filters[$indexName]['enabled']);
self::assertEquals($enabled, $filters[$indexName]['enabled']);
}

$this->assertEquals($filterName, $filters[$indexName]['filter']);
$this->assertEquals($methodName, $filters[$indexName]['method']);
self::assertEquals($filterName, $filters[$indexName]['filter']);
self::assertEquals($methodName, $filters[$indexName]['method']);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Tests/DependencyInjection/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Symfony\Component\Yaml\Yaml;

/**
* ExtenionTest
* Class ExtenionTest
*
* @author Ronald Drenth <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @link https://github.com/rdrenth/twig-extension-bundle
*/
class ExtenionTest extends \PHPUnit_Framework_TestCase
final class ExtenionTest extends \PHPUnit_Framework_TestCase
{
/**
* Test DI container with default config
Expand All @@ -23,9 +23,9 @@ public function testDefaultContainer()
$config = Yaml::parse(file_get_contents(__DIR__ . '/../Resources/config/default.yml'));
$container = $this->getContainer($config);

$this->assertTrue($container->hasDefinition('rdrenth_twig_extension.stringy'));
self::assertTrue($container->hasDefinition('rdrenth_twig_extension.stringy'));

$this->assertEquals(
self::assertEquals(
$container->getParameterBag()->resolveValue('%rdrenth_twig_extension.stringy.class%'),
$container->getDefinition('rdrenth_twig_extension.stringy')->getClass()
);
Expand Down
4 changes: 3 additions & 1 deletion Tests/Resources/config/stringy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ rdrenth_twig_extension:
slugify: ~
titleize: ~
underscored: ~
lcfirst: ~
ucfirst: ~
extra_filters:
- { filter: swap_case, method: swapCase }
- { filter: swap_case, method: swapCase }
Loading

0 comments on commit d3e2615

Please sign in to comment.