├── .gitignore ├── vendor ├── composer │ ├── installers │ │ ├── .gitignore │ │ ├── tests │ │ │ ├── bootstrap.php │ │ │ └── Composer │ │ │ │ └── Installers │ │ │ │ └── Test │ │ │ │ ├── PimcoreInstallerTest.php │ │ │ │ ├── AsgardInstallerTest.php │ │ │ │ ├── PiwikInstallerTest.php │ │ │ │ ├── TestCase.php │ │ │ │ ├── OctoberInstallerTest.php │ │ │ │ ├── MediaWikiInstallerTest.php │ │ │ │ ├── DokuWikiInstallerTest.php │ │ │ │ ├── CraftInstallerTest.php │ │ │ │ ├── GravInstallerTest.php │ │ │ │ └── CakePHPInstallerTest.php │ │ ├── .editorconfig │ │ ├── src │ │ │ ├── Composer │ │ │ │ └── Installers │ │ │ │ │ ├── ElggInstaller.php │ │ │ │ │ ├── PPIInstaller.php │ │ │ │ │ ├── KohanaInstaller.php │ │ │ │ │ ├── AimeosInstaller.php │ │ │ │ │ ├── LaravelInstaller.php │ │ │ │ │ ├── MakoInstaller.php │ │ │ │ │ ├── FuelphpInstaller.php │ │ │ │ │ ├── WolfCMSInstaller.php │ │ │ │ │ ├── MODULEWorkInstaller.php │ │ │ │ │ ├── PuppetInstaller.php │ │ │ │ │ ├── WHMCSInstaller.php │ │ │ │ │ ├── BonefishInstaller.php │ │ │ │ │ ├── SMFInstaller.php │ │ │ │ │ ├── KodiCMSInstaller.php │ │ │ │ │ ├── PrestashopInstaller.php │ │ │ │ │ ├── ClanCatsFrameworkInstaller.php │ │ │ │ │ ├── ChefInstaller.php │ │ │ │ │ ├── LithiumInstaller.php │ │ │ │ │ ├── ZikulaInstaller.php │ │ │ │ │ ├── ZendInstaller.php │ │ │ │ │ ├── KirbyInstaller.php │ │ │ │ │ ├── PhpBBInstaller.php │ │ │ │ │ ├── RedaxoInstaller.php │ │ │ │ │ ├── FuelInstaller.php │ │ │ │ │ ├── MagentoInstaller.php │ │ │ │ │ ├── AnnotateCmsInstaller.php │ │ │ │ │ ├── ImageCMSInstaller.php │ │ │ │ │ ├── WordPressInstaller.php │ │ │ │ │ ├── CodeIgniterInstaller.php │ │ │ │ │ ├── Concrete5Installer.php │ │ │ │ │ ├── DolibarrInstaller.php │ │ │ │ │ ├── Plugin.php │ │ │ │ │ ├── TheliaInstaller.php │ │ │ │ │ ├── TYPO3CmsInstaller.php │ │ │ │ │ ├── TuskInstaller.php │ │ │ │ │ ├── JoomlaInstaller.php │ │ │ │ │ ├── DrupalInstaller.php │ │ │ │ │ ├── AglInstaller.php │ │ │ │ │ ├── MODXEvoInstaller.php │ │ │ │ │ ├── RoundcubeInstaller.php │ │ │ │ │ ├── CroogoInstaller.php │ │ │ │ │ ├── PimcoreInstaller.php │ │ │ │ │ ├── Symfony1Installer.php │ │ │ │ │ ├── MauticInstaller.php │ │ │ │ │ ├── HuradInstaller.php │ │ │ │ │ ├── GravInstaller.php │ │ │ │ │ ├── PiwikInstaller.php │ │ │ │ │ ├── CraftInstaller.php │ │ │ │ │ ├── AsgardInstaller.php │ │ │ │ │ ├── SilverStripeInstaller.php │ │ │ │ │ ├── OctoberInstaller.php │ │ │ │ │ ├── TYPO3FlowInstaller.php │ │ │ │ │ ├── DokuWikiInstaller.php │ │ │ │ │ ├── MediaWikiInstaller.php │ │ │ │ │ ├── OxidInstaller.php │ │ │ │ │ ├── ShopwareInstaller.php │ │ │ │ │ ├── CakePHPInstaller.php │ │ │ │ │ ├── MoodleInstaller.php │ │ │ │ │ ├── MicroweberInstaller.php │ │ │ │ │ ├── BitrixInstaller.php │ │ │ │ │ ├── BaseInstaller.php │ │ │ │ │ └── Installer.php │ │ │ └── bootstrap.php │ │ ├── .travis.yml │ │ ├── phpunit.xml.dist │ │ ├── LICENSE │ │ ├── composer.json │ │ └── README.md │ ├── autoload_classmap.php │ ├── autoload_namespaces.php │ ├── autoload_psr4.php │ ├── LICENSE │ ├── autoload_real.php │ ├── installed.json │ └── ClassLoader.php ├── autoload.php └── davechild │ └── textstatistics │ ├── phpunit.xml.dist │ ├── .travis.yml │ ├── src │ └── DaveChild │ │ └── TextStatistics │ │ ├── resources │ │ └── Homographs.txt │ │ ├── Resource.php │ │ ├── Pluralise.php │ │ ├── Maths.php │ │ ├── Text.php │ │ └── Syllables.php │ ├── composer.json │ ├── LICENSE │ ├── tests │ ├── TextStatisticsPluralise.php │ └── TextStatisticsMaths.php │ └── README.md ├── translations ├── fr.php └── de.php ├── config.php ├── composer.json ├── releases.json ├── models └── TextStatisticsModel.php ├── twigextensions └── TextStatisticsTwigExtension.php ├── TextStatisticsPlugin.php ├── readme.md └── services └── TextStatisticsService.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *Thumbs.db 3 | composer.lock 4 | -------------------------------------------------------------------------------- /vendor/composer/installers/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock 3 | .idea/ 4 | -------------------------------------------------------------------------------- /translations/fr.php: -------------------------------------------------------------------------------- 1 | 'moins de 5 minutes', 5 | 'minutes' => 'minutes', 6 | ]; 7 | -------------------------------------------------------------------------------- /translations/de.php: -------------------------------------------------------------------------------- 1 | 'weniger als 5 Minuten', 5 | 'minutes' => 'Minuten', 6 | ]; 7 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | add('Composer\Installers\Test', __DIR__); 5 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | 200, 5 | 'readingTimeTemplate' => "{{ min < 5 ? 'less than 5 minutes'|t : min ~ ' ' ~ 'minutes'|t }}", 6 | ]; 7 | -------------------------------------------------------------------------------- /vendor/composer/installers/.editorconfig: -------------------------------------------------------------------------------- 1 | ; top-most EditorConfig file 2 | root = true 3 | 4 | ; Unix-style newlines 5 | [*] 6 | end_of_line = LF 7 | 8 | [*.php] 9 | indent_style = space 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | 'mod/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PPIInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php: -------------------------------------------------------------------------------- 1 | 'ext/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php: -------------------------------------------------------------------------------- 1 | 'libraries/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MakoInstaller.php: -------------------------------------------------------------------------------- 1 | 'app/packages/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php: -------------------------------------------------------------------------------- 1 | 'components/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php: -------------------------------------------------------------------------------- 1 | 'wolf/plugins/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/gateways/{$name}/', 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php: -------------------------------------------------------------------------------- 1 | 'Packages/{$vendor}/{$name}/' 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "carlcs/craft-textstatistics", 3 | "description": "Text Statistics plugin for Craft CMS", 4 | "type": "craft-plugin", 5 | "require": { 6 | "composer/installers": "~1.0", 7 | "php": ">=5.4.0", 8 | "davechild/textstatistics": "1.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/SMFInstaller.php: -------------------------------------------------------------------------------- 1 | 'Sources/{$name}/', 8 | 'theme' => 'Themes/{$name}/', 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/autoload_namespaces.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/davechild/textstatistics/src'), 10 | ); 11 | -------------------------------------------------------------------------------- /vendor/composer/autoload_psr4.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/composer/installers/src/Composer/Installers'), 10 | ); 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php: -------------------------------------------------------------------------------- 1 | 'cms/plugins/{$name}/', 8 | 'media' => 'cms/media/vendor/{$name}/' 9 | ); 10 | } -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 8 | 'theme' => 'themes/{$name}/', 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php: -------------------------------------------------------------------------------- 1 | 'CCF/orbit/{$name}/', 8 | 'theme' => 'CCF/app/themes/{$name}/', 9 | ); 10 | } -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ChefInstaller.php: -------------------------------------------------------------------------------- 1 | 'Chef/{$vendor}/{$name}/', 8 | 'role' => 'Chef/roles/{$name}/', 9 | ); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php: -------------------------------------------------------------------------------- 1 | 'libraries/{$name}/', 8 | 'source' => 'libraries/_source/{$name}/', 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$vendor}-{$name}/', 8 | 'theme' => 'themes/{$vendor}-{$name}/' 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.3 5 | - 5.4 6 | - 5.5 7 | - 5.6 8 | - 7.0 9 | - hhvm 10 | 11 | matrix: 12 | fast_finish: true 13 | allow_failures: 14 | - php: 7.0 15 | 16 | before_script: 17 | - composer self-update 18 | - composer install 19 | 20 | script: 21 | - composer test 22 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ZendInstaller.php: -------------------------------------------------------------------------------- 1 | 'library/{$name}/', 8 | 'extra' => 'extras/library/{$name}/', 9 | 'module' => 'module/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | ./tests/ 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php: -------------------------------------------------------------------------------- 1 | 'site/plugins/{$name}/', 8 | 'field' => 'site/fields/{$name}/', 9 | 'tag' => 'site/tags/{$name}/' 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php: -------------------------------------------------------------------------------- 1 | 'ext/{$vendor}/{$name}/', 8 | 'language' => 'language/{$name}/', 9 | 'style' => 'styles/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php: -------------------------------------------------------------------------------- 1 | 'redaxo/include/addons/{$name}/', 8 | 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/FuelInstaller.php: -------------------------------------------------------------------------------- 1 | 'fuel/app/modules/{$name}/', 8 | 'package' => 'fuel/packages/{$name}/', 9 | 'theme' => 'fuel/app/themes/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php: -------------------------------------------------------------------------------- 1 | 'app/design/frontend/{$name}/', 8 | 'skin' => 'skin/frontend/default/{$name}/', 9 | 'library' => 'lib/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | before_script: 3 | - wget http://getcomposer.org/composer.phar 4 | - php composer.phar install --dev 5 | php: 6 | - 5.3 7 | script: phpunit --coverage-clover=coverage.clover 8 | after_script: 9 | - wget https://scrutinizer-ci.com/ocular.phar 10 | - php ocular.phar code-coverage:upload --format=php-clover coverage.clover 11 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php: -------------------------------------------------------------------------------- 1 | 'addons/modules/{$name}/', 8 | 'component' => 'addons/components/{$name}/', 9 | 'service' => 'addons/services/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php: -------------------------------------------------------------------------------- 1 | 'templates/{$name}/', 8 | 'module' => 'application/modules/{$name}/', 9 | 'library' => 'application/libraries/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php: -------------------------------------------------------------------------------- 1 | 'wp-content/plugins/{$name}/', 8 | 'theme' => 'wp-content/themes/{$name}/', 9 | 'muplugin' => 'wp-content/mu-plugins/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php: -------------------------------------------------------------------------------- 1 | 'application/libraries/{$name}/', 8 | 'third-party' => 'application/third_party/{$name}/', 9 | 'module' => 'application/modules/{$name}/', 10 | ); 11 | } 12 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php: -------------------------------------------------------------------------------- 1 | 'blocks/{$name}/', 8 | 'package' => 'packages/{$name}/', 9 | 'theme' => 'themes/{$name}/', 10 | 'update' => 'updates/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/resources/Homographs.txt: -------------------------------------------------------------------------------- 1 | Homographs which have different syllables depending upon their meaning. 2 | 3 | agape 4 | aged 5 | blessed 6 | coax 7 | coop 8 | crooked 9 | cube 10 | denier 11 | dogged 12 | ewe 13 | file 14 | fine 15 | forte 16 | hades 17 | jagged 18 | lame 19 | learned 20 | legged 21 | lineage 22 | mare 23 | moped 24 | pate 25 | prayer 26 | ragged 27 | real 28 | rose 29 | sake 30 | separate 31 | tier 32 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class DolibarrInstaller extends BaseInstaller 11 | { 12 | //TODO: Add support for scripts and themes 13 | protected $locations = array( 14 | 'module' => 'htdocs/custom/{$name}/', 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/Plugin.php: -------------------------------------------------------------------------------- 1 | getInstallationManager()->addInstaller($installer); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php: -------------------------------------------------------------------------------- 1 | 'local/modules/{$name}/', 8 | 'frontoffice-template' => 'templates/frontOffice/{$name}/', 9 | 'backoffice-template' => 'templates/backOffice/{$name}/', 10 | 'email-template' => 'templates/email/{$name}/', 11 | ); 12 | } 13 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class TYPO3CmsInstaller extends BaseInstaller 12 | { 13 | protected $locations = array( 14 | 'extension' => 'typo3conf/ext/{$name}/', 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/TuskInstaller.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | class TuskInstaller extends BaseInstaller 8 | { 9 | protected $locations = array( 10 | 'task' => '.tusk/tasks/{$name}/', 11 | 'command' => '.tusk/commands/{$name}/', 12 | 'asset' => 'assets/tusk/{$name}/', 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php: -------------------------------------------------------------------------------- 1 | 'components/{$name}/', 8 | 'module' => 'modules/{$name}/', 9 | 'template' => 'templates/{$name}/', 10 | 'plugin' => 'plugins/{$name}/', 11 | 'library' => 'libraries/{$name}/', 12 | ); 13 | 14 | // TODO: Add inflector for mod_ and com_ names 15 | } 16 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/bootstrap.php: -------------------------------------------------------------------------------- 1 | 'core/', 8 | 'module' => 'modules/{$name}/', 9 | 'theme' => 'themes/{$name}/', 10 | 'library' => 'libraries/{$name}/', 11 | 'profile' => 'profiles/{$name}/', 12 | 'drush' => 'drush/{$name}/', 13 | 'custom-theme' => 'themes/custom/{$name}/', 14 | 'custom-module' => 'modules/custom/{$name}', 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/AglInstaller.php: -------------------------------------------------------------------------------- 1 | 'More/{$name}/', 8 | ); 9 | 10 | /** 11 | * Format package name to CamelCase 12 | */ 13 | public function inflectPackageVars($vars) 14 | { 15 | $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { 16 | return strtoupper($matches[1]); 17 | }, $vars['name']); 18 | 19 | return $vars; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php: -------------------------------------------------------------------------------- 1 | 'assets/snippets/{$name}/', 11 | 'plugin' => 'assets/plugins/{$name}/', 12 | 'module' => 'assets/modules/{$name}/', 13 | 'template' => 'assets/templates/{$name}/', 14 | 'lib' => 'assets/lib/{$name}/' 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php: -------------------------------------------------------------------------------- 1 | 'plugins/{$name}/', 8 | ); 9 | 10 | /** 11 | * Lowercase name and changes the name to a underscores 12 | * 13 | * @param array $vars 14 | * @return array 15 | */ 16 | public function inflectPackageVars($vars) 17 | { 18 | $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); 19 | 20 | return $vars; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php: -------------------------------------------------------------------------------- 1 | 'Plugin/{$name}/', 8 | 'theme' => 'View/Themed/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name to CamelCase 13 | */ 14 | public function inflectPackageVars($vars) 15 | { 16 | $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); 17 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 18 | 19 | return $vars; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php: -------------------------------------------------------------------------------- 1 | 'plugins/{$name}/', 8 | ); 9 | 10 | /** 11 | * Format package name to CamelCase 12 | */ 13 | public function inflectPackageVars($vars) 14 | { 15 | $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 16 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 17 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 18 | 19 | return $vars; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | class Symfony1Installer extends BaseInstaller 10 | { 11 | protected $locations = array( 12 | 'plugin' => 'plugins/{$name}/', 13 | ); 14 | 15 | /** 16 | * Format package name to CamelCase 17 | */ 18 | public function inflectPackageVars($vars) 19 | { 20 | $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { 21 | return strtoupper($matches[0][1]); 22 | }, $vars['name']); 23 | 24 | return $vars; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MauticInstaller.php: -------------------------------------------------------------------------------- 1 | 'plugins/{$name}/', 8 | 'theme' => 'themes/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name of mautic-plugins to CamelCase 13 | */ 14 | public function inflectPackageVars($vars) 15 | { 16 | if ($vars['type'] == 'mautic-plugin') { 17 | $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { 18 | return strtoupper($matches[0][1]); 19 | }, ucfirst($vars['name'])); 20 | } 21 | 22 | return $vars; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /vendor/composer/installers/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | tests/Composer/Installers 17 | 18 | 19 | 20 | 21 | 22 | src/Composer/Installers 23 | 24 | 25 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/HuradInstaller.php: -------------------------------------------------------------------------------- 1 | 'plugins/{$name}/', 8 | 'theme' => 'plugins/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name to CamelCase 13 | */ 14 | public function inflectPackageVars($vars) 15 | { 16 | $nameParts = explode('/', $vars['name']); 17 | foreach ($nameParts as &$value) { 18 | $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 19 | $value = str_replace(array('-', '_'), ' ', $value); 20 | $value = str_replace(' ', '', ucwords($value)); 21 | } 22 | $vars['name'] = implode('/', $nameParts); 23 | return $vars; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/GravInstaller.php: -------------------------------------------------------------------------------- 1 | 'user/plugins/{$name}/', 8 | 'theme' => 'user/themes/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name 13 | * 14 | * @param array $vars 15 | * 16 | * @return array 17 | */ 18 | public function inflectPackageVars($vars) 19 | { 20 | $restrictedWords = implode('|', array_keys($this->locations)); 21 | 22 | $vars['name'] = strtolower($vars['name']); 23 | $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', 24 | '$1', 25 | $vars['name'] 26 | ); 27 | 28 | return $vars; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php: -------------------------------------------------------------------------------- 1 | 'plugins/{$name}/', 16 | ); 17 | 18 | /** 19 | * Format package name to CamelCase 20 | * @param array $vars 21 | * 22 | * @return array 23 | */ 24 | public function inflectPackageVars($vars) 25 | { 26 | $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); 27 | $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); 28 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 29 | 30 | return $vars; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /models/TextStatisticsModel.php: -------------------------------------------------------------------------------- 1 | AttributeType::Number, 15 | 'letterCount' => AttributeType::Number, 16 | 'syllableCount' => AttributeType::Number, 17 | 'wordCount' => AttributeType::Number, 18 | 'sentenceCount' => AttributeType::Number, 19 | 20 | 'readingTime' => AttributeType::Mixed, 21 | 'readingTimeMinutes' => AttributeType::Number, 22 | 'readingTimeString' => AttributeType::String, 23 | 24 | 'gunningFog' => array(AttributeType::Number, 'decimals' => 4), 25 | 'fleschKincaid' => array(AttributeType::Number, 'decimals' => 4), 26 | ]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/CraftInstaller.php: -------------------------------------------------------------------------------- 1 | 'craft/plugins/{$name}/', 14 | ); 15 | 16 | /** 17 | * Strip `craft-` prefix and/or `-plugin` suffix from package names 18 | * 19 | * @param array $vars 20 | * 21 | * @return array 22 | */ 23 | final public function inflectPackageVars($vars) 24 | { 25 | return $this->inflectPluginVars($vars); 26 | } 27 | 28 | private function inflectPluginVars($vars) 29 | { 30 | $vars['name'] = preg_replace('/-' . self::NAME_SUFFIX . '$/i', '', $vars['name']); 31 | $vars['name'] = preg_replace('/^' . self::NAME_PREFIX . '-/i', '', $vars['name']); 32 | 33 | return $vars; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "davechild/textstatistics", 3 | "description": "PHP package to measure the readability of text according to various algorithms.", 4 | "homepage": "https://github.com/DaveChild/Text-Statistics", 5 | "authors": [ 6 | { 7 | "name": "Dave Child", 8 | "email": "dave@addedbytes.com", 9 | "homepage": "https://www.addedbytes.com/", 10 | "role": "Developer" 11 | } 12 | ], 13 | "license": "BSD-2-Clause", 14 | "require": { 15 | "php": ">=5.3.0" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "4.2.*" 19 | }, 20 | "autoload": { 21 | "psr-0" : { 22 | "DaveChild\\TextStatistics" : "src" 23 | } 24 | }, 25 | "extra": { 26 | "branch-alias": { 27 | "dev-master": "1.0.x-dev" 28 | } 29 | }, 30 | "suggest": { 31 | "ext-bcmath": "More accurate floating point calculations.", 32 | "ext-mbstring": "Handle multi-byte text properly." 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/composer/installers/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Kyle Robinson Young 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/composer/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2015 Nils Adermann, Jordi Boggiano 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is furnished 9 | to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php: -------------------------------------------------------------------------------- 1 | 'Modules/{$name}/', 8 | 'theme' => 'Themes/{$name}/' 9 | ); 10 | 11 | /** 12 | * Format package name. 13 | * 14 | * For package type asgard-module, cut off a trailing '-plugin' if present. 15 | * 16 | * For package type asgard-theme, cut off a trailing '-theme' if present. 17 | * 18 | */ 19 | public function inflectPackageVars($vars) 20 | { 21 | if ($vars['type'] === 'asgard-module') { 22 | return $this->inflectPluginVars($vars); 23 | } 24 | 25 | if ($vars['type'] === 'asgard-theme') { 26 | return $this->inflectThemeVars($vars); 27 | } 28 | 29 | return $vars; 30 | } 31 | 32 | protected function inflectPluginVars($vars) 33 | { 34 | $vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name'])); 35 | 36 | return $vars; 37 | } 38 | 39 | protected function inflectThemeVars($vars) 40 | { 41 | $vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name'])); 42 | 43 | return $vars; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /twigextensions/TextStatisticsTwigExtension.php: -------------------------------------------------------------------------------- 1 | textStatistics, 'getTextStatistics']), 25 | new \Twig_SimpleFunction('addToTextStatistics', [craft()->textStatistics, 'addToTextStatistics']), 26 | new \Twig_SimpleFunction('addToReadingTime', [craft()->textStatistics, 'addToReadingTime']), 27 | ]; 28 | } 29 | 30 | /** 31 | * Returns a list of filters to add to the existing list. 32 | * 33 | * @return array An array of filters 34 | */ 35 | public function getFilters() 36 | { 37 | return [ 38 | new \Twig_SimpleFilter('addToTextStatistics', [craft()->textStatistics, 'addToTextStatistics']), 39 | ]; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php: -------------------------------------------------------------------------------- 1 | '{$name}/', 10 | 'theme' => 'themes/{$name}/', 11 | ); 12 | 13 | /** 14 | * Return the install path based on package type. 15 | * 16 | * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework 17 | * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 18 | * 19 | * @param PackageInterface $package 20 | * @param string $frameworkType 21 | * @return string 22 | */ 23 | public function getInstallPath(PackageInterface $package, $frameworkType = '') 24 | { 25 | if ( 26 | $package->getName() == 'silverstripe/framework' 27 | && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) 28 | && version_compare($package->getVersion(), '2.999.999') < 0 29 | ) { 30 | return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); 31 | } else { 32 | return parent::getInstallPath($package, $frameworkType); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php: -------------------------------------------------------------------------------- 1 | 'modules/{$name}/', 8 | 'plugin' => 'plugins/{$vendor}/{$name}/', 9 | 'theme' => 'themes/{$name}/' 10 | ); 11 | 12 | /** 13 | * Format package name. 14 | * 15 | * For package type october-plugin, cut off a trailing '-plugin' if present. 16 | * 17 | * For package type october-theme, cut off a trailing '-theme' if present. 18 | * 19 | */ 20 | public function inflectPackageVars($vars) 21 | { 22 | if ($vars['type'] === 'october-plugin') { 23 | return $this->inflectPluginVars($vars); 24 | } 25 | 26 | if ($vars['type'] === 'october-theme') { 27 | return $this->inflectThemeVars($vars); 28 | } 29 | 30 | return $vars; 31 | } 32 | 33 | protected function inflectPluginVars($vars) 34 | { 35 | $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); 36 | 37 | return $vars; 38 | } 39 | 40 | protected function inflectThemeVars($vars) 41 | { 42 | $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); 43 | 44 | return $vars; 45 | } 46 | } -------------------------------------------------------------------------------- /TextStatisticsPlugin.php: -------------------------------------------------------------------------------- 1 | 'Packages/Application/{$name}/', 11 | 'framework' => 'Packages/Framework/{$name}/', 12 | 'plugin' => 'Packages/Plugins/{$name}/', 13 | 'site' => 'Packages/Sites/{$name}/', 14 | 'boilerplate' => 'Packages/Boilerplates/{$name}/', 15 | 'build' => 'Build/{$name}/', 16 | ); 17 | 18 | /** 19 | * Modify the package name to be a TYPO3 Flow style key. 20 | * 21 | * @param array $vars 22 | * @return array 23 | */ 24 | public function inflectPackageVars($vars) 25 | { 26 | $autoload = $this->package->getAutoload(); 27 | if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) { 28 | $namespace = key($autoload['psr-0']); 29 | $vars['name'] = str_replace('\\', '.', $namespace); 30 | } 31 | if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) { 32 | $namespace = key($autoload['psr-4']); 33 | $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.'); 34 | } 35 | 36 | return $vars; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | $path) { 28 | $loader->set($namespace, $path); 29 | } 30 | 31 | $map = require __DIR__ . '/autoload_psr4.php'; 32 | foreach ($map as $namespace => $path) { 33 | $loader->setPsr4($namespace, $path); 34 | } 35 | 36 | $classMap = require __DIR__ . '/autoload_classmap.php'; 37 | if ($classMap) { 38 | $loader->addClassMap($classMap); 39 | } 40 | 41 | $loader->register(true); 42 | 43 | return $loader; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php: -------------------------------------------------------------------------------- 1 | 'lib/plugins/{$name}/', 8 | 'template' => 'lib/tpl/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name. 13 | * 14 | * For package type dokuwiki-plugin, cut off a trailing '-plugin', 15 | * or leading dokuwiki_ if present. 16 | * 17 | * For package type dokuwiki-template, cut off a trailing '-template' if present. 18 | * 19 | */ 20 | public function inflectPackageVars($vars) 21 | { 22 | 23 | if ($vars['type'] === 'dokuwiki-plugin') { 24 | return $this->inflectPluginVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'dokuwiki-template') { 28 | return $this->inflectTemplateVars($vars); 29 | } 30 | 31 | return $vars; 32 | } 33 | 34 | protected function inflectPluginVars($vars) 35 | { 36 | $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); 37 | $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); 38 | 39 | return $vars; 40 | } 41 | 42 | protected function inflectTemplateVars($vars) 43 | { 44 | $vars['name'] = preg_replace('/-template$/', '', $vars['name']); 45 | $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); 46 | 47 | return $vars; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php: -------------------------------------------------------------------------------- 1 | 'extensions/{$name}/', 8 | 'skin' => 'skins/{$name}/', 9 | ); 10 | 11 | /** 12 | * Format package name. 13 | * 14 | * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform 15 | * to CamelCase keeping existing uppercase chars. 16 | * 17 | * For package type mediawiki-skin, cut off a trailing '-skin' if present. 18 | * 19 | */ 20 | public function inflectPackageVars($vars) 21 | { 22 | 23 | if ($vars['type'] === 'mediawiki-extension') { 24 | return $this->inflectExtensionVars($vars); 25 | } 26 | 27 | if ($vars['type'] === 'mediawiki-skin') { 28 | return $this->inflectSkinVars($vars); 29 | } 30 | 31 | return $vars; 32 | } 33 | 34 | protected function inflectExtensionVars($vars) 35 | { 36 | $vars['name'] = preg_replace('/-extension$/', '', $vars['name']); 37 | $vars['name'] = str_replace('-', ' ', $vars['name']); 38 | $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); 39 | 40 | return $vars; 41 | } 42 | 43 | protected function inflectSkinVars($vars) 44 | { 45 | $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); 46 | 47 | return $vars; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/Resource.php: -------------------------------------------------------------------------------- 1 | package = new Package('CamelCased', '1.0', '1.0'); 21 | $this->io = $this->getMock('Composer\IO\PackageInterface'); 22 | $this->composer = new Composer(); 23 | } 24 | 25 | /** 26 | * testInflectPackageVars 27 | * 28 | * @return void 29 | */ 30 | public function testInflectPackageVars() 31 | { 32 | $installer = new PimcoreInstaller($this->package, $this->composer); 33 | $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); 34 | $this->assertEquals($result, array('name' => 'CamelCased')); 35 | 36 | $installer = new PimcoreInstaller($this->package, $this->composer); 37 | $result = $installer->inflectPackageVars(array('name' => 'with-dash')); 38 | $this->assertEquals($result, array('name' => 'WithDash')); 39 | 40 | $installer = new PimcoreInstaller($this->package, $this->composer); 41 | $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); 42 | $this->assertEquals($result, array('name' => 'WithUnderscore')); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/OxidInstaller.php: -------------------------------------------------------------------------------- 1 | .+)\/.+/'; 9 | 10 | protected $locations = array( 11 | 'module' => 'modules/{$name}/', 12 | 'theme' => 'application/views/{$name}/', 13 | 'out' => 'out/{$name}/', 14 | ); 15 | 16 | /** 17 | * getInstallPath 18 | * 19 | * @param PackageInterface $package 20 | * @param string $frameworkType 21 | * @return void 22 | */ 23 | public function getInstallPath(PackageInterface $package, $frameworkType = '') 24 | { 25 | $installPath = parent::getInstallPath($package, $frameworkType); 26 | $type = $this->package->getType(); 27 | if ($type === 'oxid-module') { 28 | $this->prepareVendorDirectory($installPath); 29 | } 30 | return $installPath; 31 | } 32 | 33 | /** 34 | * prepareVendorDirectory 35 | * 36 | * Makes sure there is a vendormetadata.php file inside 37 | * the vendor folder if there is a vendor folder. 38 | * 39 | * @param string $installPath 40 | * @return void 41 | */ 42 | protected function prepareVendorDirectory($installPath) 43 | { 44 | $matches = ''; 45 | $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); 46 | if (!$hasVendorDirectory) { 47 | return; 48 | } 49 | 50 | $vendorDirectory = $matches['vendor']; 51 | $vendorPath = getcwd() . '/modules/' . $vendorDirectory; 52 | if (!file_exists($vendorPath)) { 53 | mkdir($vendorPath, 0755, true); 54 | } 55 | 56 | $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; 57 | touch($vendorMetaDataPath); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php: -------------------------------------------------------------------------------- 1 | 'engine/Shopware/Plugins/Local/Backend/{$name}/', 12 | 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', 13 | 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', 14 | 'theme' => 'templates/{$name}/' 15 | ); 16 | 17 | /** 18 | * Transforms the names 19 | * @param array $vars 20 | * @return array 21 | */ 22 | public function inflectPackageVars($vars) 23 | { 24 | if ($vars['type'] === 'shopware-theme') { 25 | return $this->correctThemeName($vars); 26 | } else { 27 | return $this->correctPluginName($vars); 28 | } 29 | } 30 | 31 | /** 32 | * Changes the name to a camelcased combination of vendor and name 33 | * @param array $vars 34 | * @return array 35 | */ 36 | private function correctPluginName($vars) 37 | { 38 | $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { 39 | return strtoupper($matches[0][1]); 40 | }, $vars['name']); 41 | 42 | $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); 43 | 44 | return $vars; 45 | } 46 | 47 | /** 48 | * Changes the name to a underscore separated name 49 | * @param array $vars 50 | * @return array 51 | */ 52 | private function correctThemeName($vars) 53 | { 54 | $vars['name'] = str_replace('-', '_', $vars['name']); 55 | 56 | return $vars; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/AsgardInstallerTest.php: -------------------------------------------------------------------------------- 1 | installer = new AsgardInstaller( 18 | new Package('NyanCat', '4.2', '4.2'), 19 | new Composer() 20 | ); 21 | } 22 | 23 | /** 24 | * @dataProvider packageNameInflectionProvider 25 | */ 26 | public function testInflectPackageVars($type, $name, $expected) 27 | { 28 | $this->assertEquals( 29 | $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), 30 | array('name' => $expected, 'type' => $type) 31 | ); 32 | } 33 | 34 | public function packageNameInflectionProvider() 35 | { 36 | return array( 37 | array( 38 | 'asgard-module', 39 | 'asgard-module', 40 | 'Asgard' 41 | ), 42 | array( 43 | 'asgard-module', 44 | 'blog', 45 | 'Blog' 46 | ), 47 | // tests that exactly one '-theme' is cut off 48 | array( 49 | 'asgard-theme', 50 | 'some-theme-theme', 51 | 'Some-theme', 52 | ), 53 | // tests that names without '-theme' suffix stay valid 54 | array( 55 | 'asgard-theme', 56 | 'someothertheme', 57 | 'Someothertheme', 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php: -------------------------------------------------------------------------------- 1 | package = new Package('VisitSummary', '1.0', '1.0'); 39 | $this->io = $this->getMock('Composer\IO\PackageInterface'); 40 | $this->composer = new Composer(); 41 | } 42 | 43 | /** 44 | * testInflectPackageVars 45 | * 46 | * @return void 47 | */ 48 | public function testInflectPackageVars() 49 | { 50 | $installer = new PiwikInstaller($this->package, $this->composer); 51 | $result = $installer->inflectPackageVars(array('name' => 'VisitSummary')); 52 | $this->assertEquals($result, array('name' => 'VisitSummary')); 53 | 54 | $installer = new PiwikInstaller($this->package, $this->composer); 55 | $result = $installer->inflectPackageVars(array('name' => 'visit-summary')); 56 | $this->assertEquals($result, array('name' => 'VisitSummary')); 57 | 58 | $installer = new PiwikInstaller($this->package, $this->composer); 59 | $result = $installer->inflectPackageVars(array('name' => 'visit_summary')); 60 | $this->assertEquals($result, array('name' => 'VisitSummary')); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Composer\Installers\Test; 14 | 15 | use Composer\Package\Version\VersionParser; 16 | use Composer\Package\Package; 17 | use Composer\Package\AliasPackage; 18 | use Composer\Package\LinkConstraint\VersionConstraint; 19 | use Composer\Util\Filesystem; 20 | 21 | abstract class TestCase extends \PHPUnit_Framework_TestCase 22 | { 23 | private static $parser; 24 | 25 | protected static function getVersionParser() 26 | { 27 | if (!self::$parser) { 28 | self::$parser = new VersionParser(); 29 | } 30 | 31 | return self::$parser; 32 | } 33 | 34 | protected function getVersionConstraint($operator, $version) 35 | { 36 | return new VersionConstraint( 37 | $operator, 38 | self::getVersionParser()->normalize($version) 39 | ); 40 | } 41 | 42 | protected function getPackage($name, $version) 43 | { 44 | $normVersion = self::getVersionParser()->normalize($version); 45 | 46 | return new Package($name, $normVersion, $version); 47 | } 48 | 49 | protected function getAliasPackage($package, $version) 50 | { 51 | $normVersion = self::getVersionParser()->normalize($version); 52 | 53 | return new AliasPackage($package, $normVersion, $version); 54 | } 55 | 56 | protected function ensureDirectoryExistsAndClear($directory) 57 | { 58 | $fs = new Filesystem(); 59 | if (is_dir($directory)) { 60 | $fs->removeDirectory($directory); 61 | } 62 | mkdir($directory, 0777, true); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php: -------------------------------------------------------------------------------- 1 | installer = new OctoberInstaller( 18 | new Package('NyanCat', '4.2', '4.2'), 19 | new Composer() 20 | ); 21 | } 22 | 23 | /** 24 | * @dataProvider packageNameInflectionProvider 25 | */ 26 | public function testInflectPackageVars($type, $name, $expected) 27 | { 28 | $this->assertEquals( 29 | $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), 30 | array('name' => $expected, 'type' => $type) 31 | ); 32 | } 33 | 34 | public function packageNameInflectionProvider() 35 | { 36 | return array( 37 | array( 38 | 'october-plugin', 39 | 'subpagelist', 40 | 'subpagelist', 41 | ), 42 | array( 43 | 'october-plugin', 44 | 'subpagelist-plugin', 45 | 'subpagelist', 46 | ), 47 | array( 48 | 'october-plugin', 49 | 'semanticoctober', 50 | 'semanticoctober', 51 | ), 52 | // tests that exactly one '-theme' is cut off 53 | array( 54 | 'october-theme', 55 | 'some-theme-theme', 56 | 'some-theme', 57 | ), 58 | // tests that names without '-theme' suffix stay valid 59 | array( 60 | 'october-theme', 61 | 'someothertheme', 62 | 'someothertheme', 63 | ), 64 | ); 65 | } 66 | } -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php: -------------------------------------------------------------------------------- 1 | installer = new MediaWikiInstaller( 18 | new Package('NyanCat', '4.2', '4.2'), 19 | new Composer() 20 | ); 21 | } 22 | 23 | /** 24 | * @dataProvider packageNameInflectionProvider 25 | */ 26 | public function testInflectPackageVars($type, $name, $expected) 27 | { 28 | $this->assertEquals( 29 | $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), 30 | array('name' => $expected, 'type'=>$type) 31 | ); 32 | } 33 | 34 | public function packageNameInflectionProvider() 35 | { 36 | return array( 37 | array( 38 | 'mediawiki-extension', 39 | 'sub-page-list', 40 | 'SubPageList', 41 | ), 42 | array( 43 | 'mediawiki-extension', 44 | 'sub-page-list-extension', 45 | 'SubPageList', 46 | ), 47 | array( 48 | 'mediawiki-extension', 49 | 'semantic-mediawiki', 50 | 'SemanticMediawiki', 51 | ), 52 | // tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions 53 | array( 54 | 'mediawiki-skin', 55 | 'some-skin-skin', 56 | 'some-skin', 57 | ), 58 | // tests that names without '-skin' suffix stay valid 59 | array( 60 | 'mediawiki-skin', 61 | 'someotherskin', 62 | 'someotherskin', 63 | ), 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/composer/installers/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "composer/installers", 3 | "type": "composer-plugin", 4 | "license": "MIT", 5 | "description": "A multi-framework Composer library installer", 6 | "keywords": [ 7 | "installer", 8 | "Aimeos", 9 | "AGL", 10 | "AnnotateCms", 11 | "Bitrix", 12 | "CakePHP", 13 | "Chef", 14 | "CodeIgniter", 15 | "concrete5", 16 | "Craft", 17 | "Croogo", 18 | "DokuWiki", 19 | "Dolibarr", 20 | "Drupal", 21 | "Elgg", 22 | "FuelPHP", 23 | "Grav", 24 | "Hurad", 25 | "ImageCMS", 26 | "Joomla", 27 | "Kohana", 28 | "Laravel", 29 | "Lithium", 30 | "Magento", 31 | "Mako", 32 | "Mautic", 33 | "MODX Evo", 34 | "MediaWiki", 35 | "OXID", 36 | "MODULEWork", 37 | "Moodle", 38 | "Piwik", 39 | "phpBB", 40 | "PPI", 41 | "Puppet", 42 | "Roundcube", 43 | "shopware", 44 | "SilverStripe", 45 | "SMF", 46 | "symfony", 47 | "Thelia", 48 | "TYPO3", 49 | "WolfCMS", 50 | "WordPress", 51 | "Zend", 52 | "Zikula" 53 | ], 54 | "homepage": "https://composer.github.io/installers/", 55 | "authors": [ 56 | { 57 | "name": "Kyle Robinson Young", 58 | "email": "kyle@dontkry.com", 59 | "homepage": "https://github.com/shama" 60 | } 61 | ], 62 | "autoload": { 63 | "psr-4": { "Composer\\Installers\\": "src/Composer/Installers" } 64 | }, 65 | "extra": { 66 | "class": "Composer\\Installers\\Plugin", 67 | "branch-alias": { 68 | "dev-master": "1.0-dev" 69 | } 70 | }, 71 | "replace": { 72 | "shama/baton": "*", 73 | "roundcube/plugin-installer": "*" 74 | }, 75 | "require": { 76 | "composer-plugin-api": "^1.0" 77 | }, 78 | "require-dev": { 79 | "composer/composer": "1.0.*@dev", 80 | "phpunit/phpunit": "4.1.*" 81 | }, 82 | "scripts": { 83 | "test": "phpunit" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php: -------------------------------------------------------------------------------- 1 | installer = new DokuWikiInstaller( 18 | new Package('NyanCat', '4.2', '4.2'), 19 | new Composer() 20 | ); 21 | } 22 | 23 | /** 24 | * @dataProvider packageNameInflectionProvider 25 | */ 26 | public function testInflectPackageVars($type, $name, $expected) 27 | { 28 | $this->assertEquals( 29 | $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), 30 | array('name' => $expected, 'type'=>$type) 31 | ); 32 | } 33 | 34 | public function packageNameInflectionProvider() 35 | { 36 | return array( 37 | array( 38 | 'dokuwiki-plugin', 39 | 'dokuwiki-test-plugin', 40 | 'test', 41 | ), 42 | array( 43 | 'dokuwiki-plugin', 44 | 'test-plugin', 45 | 'test', 46 | ), 47 | array( 48 | 'dokuwiki-plugin', 49 | 'dokuwiki_test', 50 | 'test', 51 | ), 52 | array( 53 | 'dokuwiki-plugin', 54 | 'test', 55 | 'test', 56 | ), 57 | array( 58 | 'dokuwiki-plugin', 59 | 'test-template', 60 | 'test-template', 61 | ), 62 | array( 63 | 'dokuwiki-template', 64 | 'dokuwiki-test-template', 65 | 'test', 66 | ), 67 | array( 68 | 'dokuwiki-template', 69 | 'test-template', 70 | 'test', 71 | ), 72 | array( 73 | 'dokuwiki-template', 74 | 'dokuwiki_test', 75 | 'test', 76 | ), 77 | array( 78 | 'dokuwiki-template', 79 | 'test', 80 | 'test', 81 | ), 82 | array( 83 | 'dokuwiki-template', 84 | 'test-plugin', 85 | 'test-plugin', 86 | ), 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/CraftInstallerTest.php: -------------------------------------------------------------------------------- 1 | installer = new CraftInstaller(); 25 | } 26 | 27 | /** 28 | * @param string $packageName 29 | * @param string $expectedName 30 | * 31 | * @covers ::inflectPackageVars 32 | * 33 | * @dataProvider provideExpectedInflectionResults 34 | */ 35 | final public function testInflectPackageVars($packageName, $expectedName) 36 | { 37 | $installer = $this->installer; 38 | 39 | $vars = array('name' => $packageName); 40 | $expected = array('name' => $expectedName); 41 | 42 | $actual = $installer->inflectPackageVars($vars); 43 | 44 | $this->assertEquals($actual, $expected); 45 | } 46 | 47 | /** 48 | * Provides various names for packages and the expected result after inflection 49 | * 50 | * @return array 51 | */ 52 | final public function provideExpectedInflectionResults() 53 | { 54 | return array( 55 | // lowercase 56 | array('foo', 'foo'), 57 | array('craftfoo', 'craftfoo'), 58 | array('fooplugin', 'fooplugin'), 59 | array('craftfooplugin', 'craftfooplugin'), 60 | // lowercase - dash 61 | array('craft-foo', 'foo'), 62 | array('foo-plugin', 'foo'), 63 | array('craft-foo-plugin', 'foo'), 64 | // lowercase - underscore 65 | array('craft_foo', 'craft_foo'), 66 | array('foo_plugin', 'foo_plugin'), 67 | array('craft_foo_plugin', 'craft_foo_plugin'), 68 | // CamelCase 69 | array('Foo', 'Foo'), 70 | array('CraftFoo', 'CraftFoo'), 71 | array('FooPlugin', 'FooPlugin'), 72 | array('CraftFooPlugin', 'CraftFooPlugin'), 73 | // CamelCase - Dash 74 | array('Craft-Foo', 'Foo'), 75 | array('Foo-Plugin', 'Foo'), 76 | array('Craft-Foo-Plugin', 'Foo'), 77 | // CamelCase - underscore 78 | array('Craft_Foo', 'Craft_Foo'), 79 | array('Foo_Plugin', 'Foo_Plugin'), 80 | array('Craft_Foo_Plugin', 'Craft_Foo_Plugin'), 81 | ); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php: -------------------------------------------------------------------------------- 1 | composer = new Composer(); 15 | } 16 | 17 | public function testInflectPackageVars() 18 | { 19 | $package = $this->getPackage('vendor/name', '0.0.0'); 20 | $installer = new GravInstaller($package, $this->composer); 21 | $packageVars = $this->getPackageVars($package); 22 | 23 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test'))); 24 | $this->assertEquals('test', $result['name']); 25 | 26 | foreach ($installer->getLocations() as $name => $location) { 27 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test"))); 28 | $this->assertEquals('test', $result['name']); 29 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name"))); 30 | $this->assertEquals('test', $result['name']); 31 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test"))); 32 | $this->assertEquals('test-test', $result['name']); 33 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name"))); 34 | $this->assertEquals('test-test', $result['name']); 35 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test"))); 36 | $this->assertEquals('test', $result['name']); 37 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name"))); 38 | $this->assertEquals('test', $result['name']); 39 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test"))); 40 | $this->assertEquals('test-test', $result['name']); 41 | $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name"))); 42 | $this->assertEquals('test-test', $result['name']); 43 | } 44 | } 45 | 46 | /** 47 | * @param $package \Composer\Package\PackageInterface 48 | */ 49 | public function getPackageVars($package) 50 | { 51 | $type = $package->getType(); 52 | 53 | $prettyName = $package->getPrettyName(); 54 | if (strpos($prettyName, '/') !== false) { 55 | list($vendor, $name) = explode('/', $prettyName); 56 | } else { 57 | $vendor = ''; 58 | $name = $prettyName; 59 | } 60 | 61 | return compact('name', 'vendor', 'type'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php: -------------------------------------------------------------------------------- 1 | 'Plugin/{$name}/', 11 | ); 12 | 13 | /** 14 | * Format package name to CamelCase 15 | */ 16 | public function inflectPackageVars($vars) 17 | { 18 | if ($this->matchesCakeVersion('>=', '3.0.0')) { 19 | return $vars; 20 | } 21 | 22 | $nameParts = explode('/', $vars['name']); 23 | foreach ($nameParts as &$value) { 24 | $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); 25 | $value = str_replace(array('-', '_'), ' ', $value); 26 | $value = str_replace(' ', '', ucwords($value)); 27 | } 28 | $vars['name'] = implode('/', $nameParts); 29 | 30 | return $vars; 31 | } 32 | 33 | /** 34 | * Change the default plugin location when cakephp >= 3.0 35 | */ 36 | public function getLocations() 37 | { 38 | if ($this->matchesCakeVersion('>=', '3.0.0')) { 39 | $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; 40 | } 41 | return $this->locations; 42 | } 43 | 44 | /** 45 | * Check if CakePHP version matches against a version 46 | * 47 | * @param string $matcher 48 | * @param string $version 49 | * @return bool 50 | */ 51 | protected function matchesCakeVersion($matcher, $version) 52 | { 53 | if (class_exists('Composer\Semver\Constraint\MultiConstraint')) { 54 | $multiClass = 'Composer\Semver\Constraint\MultiConstraint'; 55 | $constraintClass = 'Composer\Semver\Constraint\Constraint'; 56 | } else { 57 | $multiClass = 'Composer\Package\LinkConstraint\MultiConstraint'; 58 | $constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint'; 59 | } 60 | 61 | $repositoryManager = $this->composer->getRepositoryManager(); 62 | if ($repositoryManager) { 63 | $repos = $repositoryManager->getLocalRepository(); 64 | if (!$repos) { 65 | return false; 66 | } 67 | $cake3 = new $multiClass(array( 68 | new $constraintClass($matcher, $version), 69 | new $constraintClass('!=', '9999999-dev'), 70 | )); 71 | $pool = new Pool('dev'); 72 | $pool->addRepository($repos); 73 | $packages = $pool->whatProvides('cakephp/cakephp'); 74 | foreach ($packages as $package) { 75 | $installed = new $constraintClass('=', $package->getVersion()); 76 | if ($cake3->matches($installed)) { 77 | return true; 78 | break; 79 | } 80 | } 81 | } 82 | return false; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php: -------------------------------------------------------------------------------- 1 | 'mod/{$name}/', 8 | 'admin_report' => 'admin/report/{$name}/', 9 | 'atto' => 'lib/editor/atto/plugins/{$name}/', 10 | 'tool' => 'admin/tool/{$name}/', 11 | 'assignment' => 'mod/assignment/type/{$name}/', 12 | 'assignsubmission' => 'mod/assign/submission/{$name}/', 13 | 'assignfeedback' => 'mod/assign/feedback/{$name}/', 14 | 'auth' => 'auth/{$name}/', 15 | 'availability' => 'availability/condition/{$name}/', 16 | 'block' => 'blocks/{$name}/', 17 | 'booktool' => 'mod/book/tool/{$name}/', 18 | 'cachestore' => 'cache/stores/{$name}/', 19 | 'cachelock' => 'cache/locks/{$name}/', 20 | 'calendartype' => 'calendar/type/{$name}/', 21 | 'format' => 'course/format/{$name}/', 22 | 'coursereport' => 'course/report/{$name}/', 23 | 'datafield' => 'mod/data/field/{$name}/', 24 | 'datapreset' => 'mod/data/preset/{$name}/', 25 | 'editor' => 'lib/editor/{$name}/', 26 | 'enrol' => 'enrol/{$name}/', 27 | 'filter' => 'filter/{$name}/', 28 | 'gradeexport' => 'grade/export/{$name}/', 29 | 'gradeimport' => 'grade/import/{$name}/', 30 | 'gradereport' => 'grade/report/{$name}/', 31 | 'gradingform' => 'grade/grading/form/{$name}/', 32 | 'local' => 'local/{$name}/', 33 | 'logstore' => 'admin/tool/log/store/{$name}/', 34 | 'ltisource' => 'mod/lti/source/{$name}/', 35 | 'ltiservice' => 'mod/lti/service/{$name}/', 36 | 'message' => 'message/output/{$name}/', 37 | 'mnetservice' => 'mnet/service/{$name}/', 38 | 'plagiarism' => 'plagiarism/{$name}/', 39 | 'portfolio' => 'portfolio/{$name}/', 40 | 'qbehaviour' => 'question/behaviour/{$name}/', 41 | 'qformat' => 'question/format/{$name}/', 42 | 'qtype' => 'question/type/{$name}/', 43 | 'quizaccess' => 'mod/quiz/accessrule/{$name}/', 44 | 'quiz' => 'mod/quiz/report/{$name}/', 45 | 'report' => 'report/{$name}/', 46 | 'repository' => 'repository/{$name}/', 47 | 'scormreport' => 'mod/scorm/report/{$name}/', 48 | 'theme' => 'theme/{$name}/', 49 | 'tinymce' => 'lib/editor/tinymce/plugins/{$name}/', 50 | 'profilefield' => 'user/profile/field/{$name}/', 51 | 'webservice' => 'webservice/{$name}/', 52 | 'workshopallocation' => 'mod/workshop/allocation/{$name}/', 53 | 'workshopeval' => 'mod/workshop/eval/{$name}/', 54 | 'workshopform' => 'mod/workshop/form/{$name}/' 55 | ); 56 | } 57 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/tests/TextStatisticsPluralise.php: -------------------------------------------------------------------------------- 1 | TextStatistics = new DaveChild\TextStatistics\TextStatistics(); 19 | $this->TextStatistics->normalise = false; 20 | } 21 | 22 | public function tearDown() 23 | { 24 | unset($this->objTextStatistics); 25 | } 26 | 27 | /* Test Pluralisation 28 | -------------------- */ 29 | public function testPluralisation() 30 | { 31 | $this->assertEquals('geese', DaveChild\TextStatistics\Pluralise::getPlural('goose')); 32 | $this->assertEquals('mice', DaveChild\TextStatistics\Pluralise::getPlural('mouse')); 33 | $this->assertEquals('houses', DaveChild\TextStatistics\Pluralise::getPlural('house')); 34 | $this->assertEquals('bananas', DaveChild\TextStatistics\Pluralise::getPlural('banana')); 35 | $this->assertEquals('quizzes', DaveChild\TextStatistics\Pluralise::getPlural('quiz')); 36 | $this->assertEquals('geese', DaveChild\TextStatistics\Pluralise::getPlural('geese')); 37 | $this->assertEquals('mice', DaveChild\TextStatistics\Pluralise::getPlural('mice')); 38 | $this->assertEquals('houses', DaveChild\TextStatistics\Pluralise::getPlural('houses')); 39 | $this->assertEquals('bananas', DaveChild\TextStatistics\Pluralise::getPlural('bananas')); 40 | $this->assertEquals('quizzes', DaveChild\TextStatistics\Pluralise::getPlural('quizzes')); 41 | $this->assertEquals('buffalo', DaveChild\TextStatistics\Pluralise::getPlural('buffalo')); 42 | $this->assertEquals('money', DaveChild\TextStatistics\Pluralise::getPlural('money')); 43 | } 44 | 45 | /* Test Singularisations 46 | -------------------- */ 47 | public function testSingularisation() 48 | { 49 | $this->assertEquals('goose', DaveChild\TextStatistics\Pluralise::getSingular('goose')); 50 | $this->assertEquals('mouse', DaveChild\TextStatistics\Pluralise::getSingular('mouse')); 51 | $this->assertEquals('house', DaveChild\TextStatistics\Pluralise::getSingular('house')); 52 | $this->assertEquals('banana', DaveChild\TextStatistics\Pluralise::getSingular('banana')); 53 | $this->assertEquals('quiz', DaveChild\TextStatistics\Pluralise::getSingular('quiz')); 54 | $this->assertEquals('goose', DaveChild\TextStatistics\Pluralise::getSingular('geese')); 55 | $this->assertEquals('mouse', DaveChild\TextStatistics\Pluralise::getSingular('mice')); 56 | $this->assertEquals('house', DaveChild\TextStatistics\Pluralise::getSingular('houses')); 57 | $this->assertEquals('banana', DaveChild\TextStatistics\Pluralise::getSingular('bananas')); 58 | $this->assertEquals('quiz', DaveChild\TextStatistics\Pluralise::getSingular('quizzes')); 59 | $this->assertEquals('buffalo', DaveChild\TextStatistics\Pluralise::getPlural('buffalo')); 60 | $this->assertEquals('money', DaveChild\TextStatistics\Pluralise::getPlural('money')); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/README.md: -------------------------------------------------------------------------------- 1 | #PHP Text Statistics 2 | 3 | [![Build Status](https://travis-ci.org/DaveChild/Text-Statistics.svg?branch=master)](https://travis-ci.org/DaveChild/Text-Statistics) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/DaveChild/Text-Statistics/?branch=master) 4 | 5 | The PHP Text Statistics class will help you to indentify issues with your website content, especially with readability. 6 | 7 | It allows you to measure the readability of text using common scoring systems, including: 8 | * Flesch Kincaid Reading Ease 9 | * Flesch Kincaid Grade Level 10 | * Gunning Fog Score 11 | * Coleman Liau Index 12 | * SMOG Index 13 | * Automated Reability Index 14 | * Dale-Chall Readability Score 15 | * Spache Readability Score 16 | 17 | One of the biggest challenges with measuring text readability is the counting of syllables, which can be tricky to work out. There are rules in the Statistics class for working out the syllable count of words, and a large list of words to test these rules against. 18 | 19 | Please feel free to add to the test word list, especially if you can find words whose syllable count is not correctly calculated (even more especially if you can also add code to the class so your word is correctly handled!). 20 | 21 | Homographs are going to be impossible to calculate as they depend on context (i.e., "he moped around the house", "she rode her moped to school), but there are few enough of these not to be a concern. There is a by-no-means-comprehensive list of these in the resources folder. 22 | 23 | ##Installation 24 | 25 | ###Using Composer 26 | 27 | { 28 | "require": { 29 | "davechild/textstatistics": "dev-master" 30 | } 31 | } 32 | 33 | ###Measuring Readability 34 | 35 | use DaveChild\TextStatistics as TS; 36 | $textStatistics = new TS\TextStatistics; 37 | $text = 'The quick brown fox jumped over the lazy dog.'; 38 | echo 'Flesch-Kincaid Reading Ease: ' . $textStatistics->fleschKincaidReadingEase($text); 39 | 40 | ###More Text Shenanigans! 41 | 42 | Included with this package are several classes with static methods which can be called independently. If required, you can pass a text encoding to these methods as a second parameter. 43 | 44 | ####Pluralise and Singularise Words 45 | 46 | echo DaveChild\TextStatistics\Pluralise::getPlural('banana'); // bananas 47 | echo DaveChild\TextStatistics\Pluralise::getSingular('bananas'); // banana 48 | 49 | ####Count Syllables 50 | 51 | echo DaveChild\TextStatistics\Syllables::syllableCount('banana'); // 3 52 | 53 | ####Letter, Sentence, Word Counts 54 | 55 | echo DaveChild\TextStatistics\Text::textLength('I ate a banana.'); // 15 56 | echo DaveChild\TextStatistics\Text::letterCount('I ate a banana.'); // 11 57 | echo DaveChild\TextStatistics\Text::wordCount('I ate a banana.'); // 4 58 | echo DaveChild\TextStatistics\Text::sentenceCount('I ate a banana.'); // 1 59 | 60 | ##Useful Links 61 | 62 | **Homepage and Live Version** 63 | 64 | https://readability-score.com/ 65 | 66 | **JavaScript Port** 67 | 68 | https://github.com/cgiffard/TextStatistics.js 69 | 70 | **License** 71 | 72 | http://www.opensource.org/licenses/bsd-license.php 73 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php: -------------------------------------------------------------------------------- 1 | 'userfiles/modules/{$name}/', 8 | 'module-skin' => 'userfiles/modules/{$name}/templates/', 9 | 'template' => 'userfiles/templates/{$name}/', 10 | 'element' => 'userfiles/elements/{$name}/', 11 | 'vendor' => 'vendor/{$name}/', 12 | 'components' => 'components/{$name}/' 13 | ); 14 | 15 | /** 16 | * Format package name. 17 | * 18 | * For package type microweber-module, cut off a trailing '-module' if present 19 | * 20 | * For package type microweber-template, cut off a trailing '-template' if present. 21 | * 22 | */ 23 | public function inflectPackageVars($vars) 24 | { 25 | if ($vars['type'] === 'microweber-template') { 26 | return $this->inflectTemplateVars($vars); 27 | } 28 | if ($vars['type'] === 'microweber-templates') { 29 | return $this->inflectTemplatesVars($vars); 30 | } 31 | if ($vars['type'] === 'microweber-core') { 32 | return $this->inflectCoreVars($vars); 33 | } 34 | if ($vars['type'] === 'microweber-adapter') { 35 | return $this->inflectCoreVars($vars); 36 | } 37 | if ($vars['type'] === 'microweber-module') { 38 | return $this->inflectModuleVars($vars); 39 | } 40 | if ($vars['type'] === 'microweber-modules') { 41 | return $this->inflectModulesVars($vars); 42 | } 43 | if ($vars['type'] === 'microweber-skin') { 44 | return $this->inflectSkinVars($vars); 45 | } 46 | if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { 47 | return $this->inflectElementVars($vars); 48 | } 49 | 50 | return $vars; 51 | } 52 | 53 | protected function inflectTemplateVars($vars) 54 | { 55 | $vars['name'] = preg_replace('/-template$/', '', $vars['name']); 56 | $vars['name'] = preg_replace('/template-$/', '', $vars['name']); 57 | 58 | return $vars; 59 | } 60 | 61 | protected function inflectTemplatesVars($vars) 62 | { 63 | $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); 64 | $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); 65 | 66 | return $vars; 67 | } 68 | 69 | protected function inflectCoreVars($vars) 70 | { 71 | $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); 72 | $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); 73 | $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); 74 | 75 | return $vars; 76 | } 77 | 78 | protected function inflectModuleVars($vars) 79 | { 80 | $vars['name'] = preg_replace('/-module$/', '', $vars['name']); 81 | $vars['name'] = preg_replace('/module-$/', '', $vars['name']); 82 | 83 | return $vars; 84 | } 85 | 86 | protected function inflectModulesVars($vars) 87 | { 88 | $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); 89 | $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); 90 | 91 | return $vars; 92 | } 93 | 94 | protected function inflectSkinVars($vars) 95 | { 96 | $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); 97 | $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); 98 | 99 | return $vars; 100 | } 101 | 102 | protected function inflectElementVars($vars) 103 | { 104 | $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); 105 | $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); 106 | $vars['name'] = preg_replace('/-element$/', '', $vars['name']); 107 | $vars['name'] = preg_replace('/element-$/', '', $vars['name']); 108 | 109 | return $vars; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php: -------------------------------------------------------------------------------- 1 | 24 | * @author Denis Kulichkin 25 | */ 26 | class BitrixInstaller extends BaseInstaller 27 | { 28 | protected $locations = array( 29 | 'module' => '{$bitrix_dir}/modules/{$name}/', 30 | 'component' => '{$bitrix_dir}/components/{$name}/', 31 | 'theme' => '{$bitrix_dir}/templates/{$name}/', 32 | ); 33 | 34 | /** 35 | * @var array Storage for informations about duplicates at all the time of installation packages. 36 | */ 37 | private static $checkedDuplicates = array(); 38 | 39 | /** 40 | * {@inheritdoc} 41 | */ 42 | public function inflectPackageVars($vars) 43 | { 44 | if ($this->composer->getPackage()) { 45 | $extra = $this->composer->getPackage()->getExtra(); 46 | 47 | if (isset($extra['bitrix-dir'])) { 48 | $vars['bitrix_dir'] = $extra['bitrix-dir']; 49 | } 50 | } 51 | 52 | if (!isset($vars['bitrix_dir'])) { 53 | $vars['bitrix_dir'] = 'bitrix'; 54 | } 55 | 56 | return parent::inflectPackageVars($vars); 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | protected function templatePath($path, array $vars = array()) 63 | { 64 | $templatePath = parent::templatePath($path, $vars); 65 | $this->checkDuplicates($templatePath, $vars); 66 | 67 | return $templatePath; 68 | } 69 | 70 | /** 71 | * Duplicates search packages. 72 | * 73 | * @param string $path 74 | * @param array $vars 75 | */ 76 | protected function checkDuplicates($path, array $vars = array()) 77 | { 78 | $packageType = substr($vars['type'], strlen('bitrix') + 1); 79 | $localDir = explode('/', $vars['bitrix_dir']); 80 | array_pop($localDir); 81 | $localDir[] = 'local'; 82 | $localDir = implode('/', $localDir); 83 | 84 | $oldPath = str_replace( 85 | array('{$bitrix_dir}', '{$name}'), 86 | array($localDir, $vars['name']), 87 | $this->locations[$packageType] 88 | ); 89 | 90 | if (in_array($oldPath, static::$checkedDuplicates)) { 91 | return; 92 | } 93 | 94 | if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) { 95 | 96 | $this->io->writeError(' Duplication of packages:'); 97 | $this->io->writeError(' Package ' . $oldPath . ' will be called instead package ' . $path . ''); 98 | 99 | while (true) { 100 | switch ($this->io->ask(' Delete ' . $oldPath . ' [y,n,?]? ', '?')) { 101 | case 'y': 102 | $fs = new Filesystem(); 103 | $fs->removeDirectory($oldPath); 104 | break 2; 105 | 106 | case 'n': 107 | break 2; 108 | 109 | case '?': 110 | default: 111 | $this->io->writeError(array( 112 | ' y - delete package ' . $oldPath . ' and to continue with the installation', 113 | ' n - don\'t delete and to continue with the installation', 114 | )); 115 | $this->io->writeError(' ? - print help'); 116 | break; 117 | } 118 | } 119 | } 120 | 121 | static::$checkedDuplicates[] = $oldPath; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/BaseInstaller.php: -------------------------------------------------------------------------------- 1 | composer = $composer; 25 | $this->package = $package; 26 | $this->io = $io; 27 | } 28 | 29 | /** 30 | * Return the install path based on package type. 31 | * 32 | * @param PackageInterface $package 33 | * @param string $frameworkType 34 | * @return string 35 | */ 36 | public function getInstallPath(PackageInterface $package, $frameworkType = '') 37 | { 38 | $type = $this->package->getType(); 39 | 40 | $prettyName = $this->package->getPrettyName(); 41 | if (strpos($prettyName, '/') !== false) { 42 | list($vendor, $name) = explode('/', $prettyName); 43 | } else { 44 | $vendor = ''; 45 | $name = $prettyName; 46 | } 47 | 48 | $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); 49 | 50 | $extra = $package->getExtra(); 51 | if (!empty($extra['installer-name'])) { 52 | $availableVars['name'] = $extra['installer-name']; 53 | } 54 | 55 | if ($this->composer->getPackage()) { 56 | $extra = $this->composer->getPackage()->getExtra(); 57 | if (!empty($extra['installer-paths'])) { 58 | $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor); 59 | if ($customPath !== false) { 60 | return $this->templatePath($customPath, $availableVars); 61 | } 62 | } 63 | } 64 | 65 | $packageType = substr($type, strlen($frameworkType) + 1); 66 | $locations = $this->getLocations(); 67 | if (!isset($locations[$packageType])) { 68 | throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); 69 | } 70 | 71 | return $this->templatePath($locations[$packageType], $availableVars); 72 | } 73 | 74 | /** 75 | * For an installer to override to modify the vars per installer. 76 | * 77 | * @param array $vars 78 | * @return array 79 | */ 80 | public function inflectPackageVars($vars) 81 | { 82 | return $vars; 83 | } 84 | 85 | /** 86 | * Gets the installer's locations 87 | * 88 | * @return array 89 | */ 90 | public function getLocations() 91 | { 92 | return $this->locations; 93 | } 94 | 95 | /** 96 | * Replace vars in a path 97 | * 98 | * @param string $path 99 | * @param array $vars 100 | * @return string 101 | */ 102 | protected function templatePath($path, array $vars = array()) 103 | { 104 | if (strpos($path, '{') !== false) { 105 | extract($vars); 106 | preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); 107 | if (!empty($matches[1])) { 108 | foreach ($matches[1] as $var) { 109 | $path = str_replace('{$' . $var . '}', $$var, $path); 110 | } 111 | } 112 | } 113 | 114 | return $path; 115 | } 116 | 117 | /** 118 | * Search through a passed paths array for a custom install path. 119 | * 120 | * @param array $paths 121 | * @param string $name 122 | * @param string $type 123 | * @param string $vendor = NULL 124 | * @return string 125 | */ 126 | protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL) 127 | { 128 | foreach ($paths as $path => $names) { 129 | if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) { 130 | return $path; 131 | } 132 | } 133 | 134 | return false; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php: -------------------------------------------------------------------------------- 1 | package = new Package('CamelCased', '1.0', '1.0'); 27 | $this->io = $this->getMock('Composer\IO\PackageInterface'); 28 | $this->composer = new Composer(); 29 | $this->composer->setConfig(new Config(false)); 30 | } 31 | 32 | /** 33 | * testInflectPackageVars 34 | * 35 | * @return void 36 | */ 37 | public function testInflectPackageVars() 38 | { 39 | $installer = new CakePHPInstaller($this->package, $this->composer); 40 | $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); 41 | $this->assertEquals($result, array('name' => 'CamelCased')); 42 | 43 | $installer = new CakePHPInstaller($this->package, $this->composer); 44 | $result = $installer->inflectPackageVars(array('name' => 'with-dash')); 45 | $this->assertEquals($result, array('name' => 'WithDash')); 46 | 47 | $installer = new CakePHPInstaller($this->package, $this->composer); 48 | $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); 49 | $this->assertEquals($result, array('name' => 'WithUnderscore')); 50 | 51 | $installer = new CakePHPInstaller($this->package, $this->composer); 52 | $result = $installer->inflectPackageVars(array('name' => 'cake/acl')); 53 | $this->assertEquals($result, array('name' => 'Cake/Acl')); 54 | 55 | $installer = new CakePHPInstaller($this->package, $this->composer); 56 | $result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit')); 57 | $this->assertEquals($result, array('name' => 'Cake/DebugKit')); 58 | } 59 | 60 | /** 61 | * Test getLocations returning appropriate values based on CakePHP version 62 | * 63 | */ 64 | public function testGetLocations() { 65 | $package = new RootPackage('CamelCased', '1.0', '1.0'); 66 | $composer = $this->composer; 67 | $rm = new RepositoryManager( 68 | $this->getMock('Composer\IO\IOInterface'), 69 | $this->getMock('Composer\Config') 70 | ); 71 | $composer->setRepositoryManager($rm); 72 | $installer = new CakePHPInstaller($package, $composer); 73 | 74 | // 2.0 < cakephp < 3.0 75 | $this->setCakephpVersion($rm, '2.0.0'); 76 | $result = $installer->getLocations(); 77 | $this->assertContains('Plugin/', $result['plugin']); 78 | 79 | $this->setCakephpVersion($rm, '2.5.9'); 80 | $result = $installer->getLocations(); 81 | $this->assertContains('Plugin/', $result['plugin']); 82 | 83 | $this->setCakephpVersion($rm, '~2.5'); 84 | $result = $installer->getLocations(); 85 | $this->assertContains('Plugin/', $result['plugin']); 86 | 87 | // special handling for 2.x versions when 3.x is still in development 88 | $this->setCakephpVersion($rm, 'dev-master'); 89 | $result = $installer->getLocations(); 90 | $this->assertContains('Plugin/', $result['plugin']); 91 | 92 | $this->setCakephpVersion($rm, '>=2.5'); 93 | $result = $installer->getLocations(); 94 | $this->assertContains('Plugin/', $result['plugin']); 95 | 96 | // cakephp >= 3.0 97 | $this->setCakephpVersion($rm, '3.0.*-dev'); 98 | $result = $installer->getLocations(); 99 | $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']); 100 | 101 | $this->setCakephpVersion($rm, '~8.8'); 102 | $result = $installer->getLocations(); 103 | $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']); 104 | } 105 | 106 | protected function setCakephpVersion($rm, $version) { 107 | $parser = new VersionParser(); 108 | list(, $version) = explode(' ', $parser->parseConstraints($version)); 109 | $installed = new InstalledArrayRepository(); 110 | $package = new Package('cakephp/cakephp', $version, $version); 111 | $installed->addPackage($package); 112 | $rm->setLocalRepository($installed); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Text Statistics plugin for Craft CMS 2 | 3 | This Craft plugin provides Twig functions to display information about your texts. It allows you to measure the readability of your content, calculate the average reading time or access other text statistics like sentence count. 4 | 5 | ## Installation 6 | 7 | The plugin is available on Packagist and can be installed using Composer. You can also download the [latest release][1] and copy the files into craft/plugins/textstatistics/. 8 | 9 | ``` 10 | $ composer require carlcs/craft-textstatistics 11 | ``` 12 | 13 | [1]: https://github.com/carlcs/craft-textstatistics/releases/latest 14 | 15 | ## Settings 16 | 17 | The plugin can be configured with a craft/config/textstatistics.php config file to set the default template used to render the reading time string and to set a default words per minute value. 18 | 19 | ## TextStatisticsModel 20 | 21 | When you generate text statistics using the getTextStatistics function the plugin returns a TextStatisticsModel with the following properties populated. Most of the data is calculated with the excellent [Text Statistics][2] library by Dave Child. For information about the provided readability scores have a look these Wikipedia articles: 22 | 23 | - [Gunning Fog Index][3] 24 | - [Flesch Kincaid Reading Ease][4] 25 | 26 | #### Properties 27 | 28 | - `textLength` 29 | - `letterCount` 30 | - `syllableCount` 31 | - `wordCount` 32 | - `sentenceCount` 33 | - `readingTime` 34 | - `readingTimeMinutes` 35 | - `readingTimeString` 36 | - `gunningFog` 37 | - `fleschKincaid` 38 | 39 | [2]: https://github.com/DaveChild/Text-Statistics 40 | [3]: https://en.wikipedia.org/wiki/Gunning_fog_index 41 | [4]: https://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests 42 | 43 | ## Templating Examples 44 | 45 | #### A single article 46 | 47 | ```twig 48 | {% do addToTextStatistics(entry.text) %} 49 | 50 | {% set statistics = getTextStatistics() %} 51 | {{ statistics.readingTimeString }} 52 | 53 | {# outputs "21 minutes" #} 54 | ``` 55 | 56 | #### Adjust WPM according to text language 57 | 58 | ```twig 59 | {% set wpm = { 60 | 'en': 200, 61 | 'fr': 180, 62 | } %} 63 | 64 | {% set statistics = getTextStatistics(null, wpm[craft.locale]) %} 65 | {{ statistics.readingTimeString }} 66 | 67 | {# outputs "moins de 5 minutes" #} 68 | ``` 69 | 70 | #### Usage with a Matrix field 71 | 72 | ```twig 73 | {% for block in entry.article %} 74 | 75 | {% if block.type == 'text' %} 76 | {% do addToTextStatistics(block.text) %} 77 | {{ block.text }} 78 | {% endif %} 79 | 80 | {% if block.type == 'image' %} 81 | {% set image = block.image.first() %} 82 | {% if image %} 83 | {% do addToReadingTime(10) %} 84 | {{ image.title }} 85 | {% endif %} 86 | {% endif %} 87 | 88 | {% endfor %} 89 | 90 | {% set statistics = getTextStatistics() %} 91 | ``` 92 | 93 | ## Twig functions 94 | 95 | #### addToTextStatistics( text, articleId ) 96 | 97 | Adds text to the data storage so you can later perform text statistics calculations from it. 98 | 99 | - **`text`** (required) – The text to add to the data storage for text statistics. It can contain HTML tags, the plugin removes them before doing its calculations. 100 | - **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page. 101 | 102 | ```twig 103 | {% do addToTextStatistics(entry.myRichTextField) %} 104 | ``` 105 | 106 | Alternativly you can use the Twig filter. 107 | 108 | ```twig 109 | {{ entry.myRichTextField|addToTextStatistics }} 110 | ``` 111 | 112 | #### addToReadingTime( seconds, articleId ) 113 | 114 | Adds time to the data storage to further influence the reading time returned with the text statistics. 115 | 116 | - **`seconds`** (required) – Time in seconds to add to the data storage for text statistics. 117 | - **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page. 118 | 119 | ```twig 120 | {% do addToReadingTime(15) %} 121 | ``` 122 | 123 | #### getTextStatistics( articleId, wpm, readingTimeTemplate ) 124 | 125 | Performs the text statistics calculations for an article and returns the result as a TextStatisticsModel. 126 | 127 | - **`articleId`** (default `''`) – An ID to identify the article. Only required if you have multiple articles for text statistics on the same page. 128 | - **`wpm`** (default `200`) – The average reading speed used for the reading time calculations in words per minute units. 129 | - **`readingTimeTemplate`** (default ) – The Twig template code used to render for the reading time string. 130 | 131 | ```twig 132 | {% set statistics = getTextStatistics() %} 133 | {{ statistics.gunningFog }} 134 | 135 | {# outputs "12.1" #} 136 | ``` 137 | 138 | ## Requirements 139 | 140 | - PHP 5.4+ 141 | -------------------------------------------------------------------------------- /vendor/composer/installed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "composer/installers", 4 | "version": "v1.0.25", 5 | "version_normalized": "1.0.25.0", 6 | "source": { 7 | "type": "git", 8 | "url": "https://github.com/composer/installers.git", 9 | "reference": "36e5b5843203d7f1cf6ffb0305a97e014387bd8e" 10 | }, 11 | "dist": { 12 | "type": "zip", 13 | "url": "https://api.github.com/repos/composer/installers/zipball/36e5b5843203d7f1cf6ffb0305a97e014387bd8e", 14 | "reference": "36e5b5843203d7f1cf6ffb0305a97e014387bd8e", 15 | "shasum": "" 16 | }, 17 | "require": { 18 | "composer-plugin-api": "^1.0" 19 | }, 20 | "replace": { 21 | "roundcube/plugin-installer": "*", 22 | "shama/baton": "*" 23 | }, 24 | "require-dev": { 25 | "composer/composer": "1.0.*@dev", 26 | "phpunit/phpunit": "4.1.*" 27 | }, 28 | "time": "2016-04-13 19:46:30", 29 | "type": "composer-plugin", 30 | "extra": { 31 | "class": "Composer\\Installers\\Plugin", 32 | "branch-alias": { 33 | "dev-master": "1.0-dev" 34 | } 35 | }, 36 | "installation-source": "dist", 37 | "autoload": { 38 | "psr-4": { 39 | "Composer\\Installers\\": "src/Composer/Installers" 40 | } 41 | }, 42 | "notification-url": "https://packagist.org/downloads/", 43 | "license": [ 44 | "MIT" 45 | ], 46 | "authors": [ 47 | { 48 | "name": "Kyle Robinson Young", 49 | "email": "kyle@dontkry.com", 50 | "homepage": "https://github.com/shama" 51 | } 52 | ], 53 | "description": "A multi-framework Composer library installer", 54 | "homepage": "https://composer.github.io/installers/", 55 | "keywords": [ 56 | "Craft", 57 | "Dolibarr", 58 | "Hurad", 59 | "ImageCMS", 60 | "MODX Evo", 61 | "Mautic", 62 | "OXID", 63 | "SMF", 64 | "Thelia", 65 | "WolfCMS", 66 | "agl", 67 | "aimeos", 68 | "annotatecms", 69 | "bitrix", 70 | "cakephp", 71 | "chef", 72 | "codeigniter", 73 | "concrete5", 74 | "croogo", 75 | "dokuwiki", 76 | "drupal", 77 | "elgg", 78 | "fuelphp", 79 | "grav", 80 | "installer", 81 | "joomla", 82 | "kohana", 83 | "laravel", 84 | "lithium", 85 | "magento", 86 | "mako", 87 | "mediawiki", 88 | "modulework", 89 | "moodle", 90 | "phpbb", 91 | "piwik", 92 | "ppi", 93 | "puppet", 94 | "roundcube", 95 | "shopware", 96 | "silverstripe", 97 | "symfony", 98 | "typo3", 99 | "wordpress", 100 | "zend", 101 | "zikula" 102 | ] 103 | }, 104 | { 105 | "name": "davechild/textstatistics", 106 | "version": "1.0.1", 107 | "version_normalized": "1.0.1.0", 108 | "source": { 109 | "type": "git", 110 | "url": "https://github.com/DaveChild/Text-Statistics.git", 111 | "reference": "6196462b4fe730a8ff0019036baf362295c161b3" 112 | }, 113 | "dist": { 114 | "type": "zip", 115 | "url": "https://api.github.com/repos/DaveChild/Text-Statistics/zipball/6196462b4fe730a8ff0019036baf362295c161b3", 116 | "reference": "6196462b4fe730a8ff0019036baf362295c161b3", 117 | "shasum": "" 118 | }, 119 | "require": { 120 | "php": ">=5.3.0" 121 | }, 122 | "require-dev": { 123 | "phpunit/phpunit": "4.2.*" 124 | }, 125 | "suggest": { 126 | "ext-bcmath": "More accurate floating point calculations.", 127 | "ext-mbstring": "Handle multi-byte text properly." 128 | }, 129 | "time": "2015-04-22 14:55:55", 130 | "type": "library", 131 | "extra": { 132 | "branch-alias": { 133 | "dev-master": "1.0.x-dev" 134 | } 135 | }, 136 | "installation-source": "dist", 137 | "autoload": { 138 | "psr-0": { 139 | "DaveChild\\TextStatistics": "src" 140 | } 141 | }, 142 | "notification-url": "https://packagist.org/downloads/", 143 | "license": [ 144 | "BSD-2-Clause" 145 | ], 146 | "authors": [ 147 | { 148 | "name": "Dave Child", 149 | "email": "dave@addedbytes.com", 150 | "homepage": "https://www.addedbytes.com/", 151 | "role": "Developer" 152 | } 153 | ], 154 | "description": "PHP package to measure the readability of text according to various algorithms.", 155 | "homepage": "https://github.com/DaveChild/Text-Statistics" 156 | } 157 | ] 158 | -------------------------------------------------------------------------------- /services/TextStatisticsService.php: -------------------------------------------------------------------------------- 1 | getArticleDataById($articleId); 37 | 38 | $articleData['additionalTime'] += $seconds; 39 | } 40 | 41 | /** 42 | * Stores additional text for an article's text statistics. 43 | * 44 | * @param int $text 45 | * @param string $articleId 46 | * 47 | * @return null 48 | */ 49 | public function addToTextStatistics($text, $articleId = '') 50 | { 51 | $articleData = &$this->getArticleDataById($articleId); 52 | 53 | $articleData['text'] .= $text; 54 | } 55 | 56 | /** 57 | * Returns the text statistics for an article. 58 | * 59 | * @param string $articleId 60 | * @param string $template 61 | * 62 | * @return TextStatisticsModel 63 | */ 64 | public function getTextStatistics($articleId = '', $wpm = null, $readingTimeTemplate = null) 65 | { 66 | if (!isset($this->articlesData[$articleId])) { 67 | return null; 68 | } 69 | 70 | $articleData = &$this->getArticleDataById($articleId); 71 | 72 | $wordCount = Text::wordCount($articleData['text']); 73 | $wpm = $wpm ?: craft()->config->get('wordsPerMinute', 'textStatistics'); 74 | 75 | // Calculate times in seconds 76 | $textReadingTime = $wordCount / $wpm * 60; 77 | $additionalTime = $articleData['additionalTime']; 78 | $totalTime = ceil($textReadingTime + $additionalTime); 79 | 80 | $readingTime = $this->getDateIntervalFromSeconds($totalTime); 81 | $readingTimeMinutes = ceil($totalTime / 60); 82 | 83 | // Render Twig template for the readingTimeString 84 | $variables = [ 85 | 'iv' => $readingTime, 86 | 'min' => $readingTimeMinutes, 87 | ]; 88 | 89 | $template = $readingTimeTemplate ?: craft()->config->get('readingTimeTemplate', 'textStatistics'); 90 | $readingTimeString = craft()->templates->renderString($template, $variables); 91 | 92 | // Populate Statistics model 93 | $model = new TextStatisticsModel(); 94 | 95 | $model->textLength = Text::textLength($articleData['text']); 96 | $model->letterCount = Text::letterCount($articleData['text']); 97 | $model->syllableCount = Syllables::syllableCount($articleData['text']); 98 | $model->wordCount = $wordCount; 99 | $model->sentenceCount = Text::sentenceCount($articleData['text']); 100 | 101 | $model->readingTime = $readingTime; 102 | $model->readingTimeMinutes = $readingTimeMinutes; 103 | $model->readingTimeString = $readingTimeString; 104 | 105 | $textStatistics = $this->getTextStatisticsClass(); 106 | 107 | $model->gunningFog = $textStatistics->gunningFogScore($articleData['text']); 108 | $model->fleschKincaid = $textStatistics->fleschKincaidReadingEase($articleData['text']); 109 | 110 | if (!$model->validate()) { 111 | throw new Exception('There was an error while generating the Text Statistics.'); 112 | } 113 | 114 | return $model; 115 | } 116 | 117 | // Protected Methods 118 | // ========================================================================= 119 | 120 | /** 121 | * Returns our TextStatistics instance. 122 | * 123 | * @return \DaveChild\TextStatistics\TextStatistics 124 | */ 125 | protected function getTextStatisticsClass() 126 | { 127 | if (!$this->textStatistics) { 128 | $this->textStatistics = new TextStatistics; 129 | } 130 | 131 | return $this->textStatistics; 132 | } 133 | 134 | /** 135 | * Returns article data by article ID 136 | * 137 | * @param string $articleId 138 | * 139 | * @return array 140 | */ 141 | protected function &getArticleDataById($articleId) 142 | { 143 | if (!isset($this->articlesData[$articleId])) { 144 | $this->articlesData[$articleId] = [ 145 | 'text' => '', 146 | 'additionalTime' => 0, 147 | ]; 148 | } 149 | 150 | return $this->articlesData[$articleId]; 151 | } 152 | 153 | /** 154 | * Creates a DateInterval object from seconds. 155 | * 156 | * @param int $seconds 157 | * 158 | * @return \Craft\DateInterval 159 | */ 160 | protected function getDateIntervalFromSeconds($seconds) 161 | { 162 | $d1 = new DateTime(); 163 | $d2 = new DateTime(); 164 | $d2->add(new DateInterval('PT'.$seconds.'S')); 165 | 166 | return $d2->diff($d1); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /vendor/composer/installers/src/Composer/Installers/Installer.php: -------------------------------------------------------------------------------- 1 | 'AimeosInstaller', 18 | 'asgard' => 'AsgardInstaller', 19 | 'agl' => 'AglInstaller', 20 | 'annotatecms' => 'AnnotateCmsInstaller', 21 | 'bitrix' => 'BitrixInstaller', 22 | 'bonefish' => 'BonefishInstaller', 23 | 'cakephp' => 'CakePHPInstaller', 24 | 'chef' => 'ChefInstaller', 25 | 'ccframework' => 'ClanCatsFrameworkInstaller', 26 | 'codeigniter' => 'CodeIgniterInstaller', 27 | 'concrete5' => 'Concrete5Installer', 28 | 'craft' => 'CraftInstaller', 29 | 'croogo' => 'CroogoInstaller', 30 | 'dokuwiki' => 'DokuWikiInstaller', 31 | 'dolibarr' => 'DolibarrInstaller', 32 | 'drupal' => 'DrupalInstaller', 33 | 'elgg' => 'ElggInstaller', 34 | 'fuel' => 'FuelInstaller', 35 | 'fuelphp' => 'FuelphpInstaller', 36 | 'grav' => 'GravInstaller', 37 | 'hurad' => 'HuradInstaller', 38 | 'imagecms' => 'ImageCMSInstaller', 39 | 'joomla' => 'JoomlaInstaller', 40 | 'kirby' => 'KirbyInstaller', 41 | 'kodicms' => 'KodiCMSInstaller', 42 | 'kohana' => 'KohanaInstaller', 43 | 'laravel' => 'LaravelInstaller', 44 | 'lithium' => 'LithiumInstaller', 45 | 'magento' => 'MagentoInstaller', 46 | 'mako' => 'MakoInstaller', 47 | 'mautic' => 'MauticInstaller', 48 | 'mediawiki' => 'MediaWikiInstaller', 49 | 'microweber' => 'MicroweberInstaller', 50 | 'modulework' => 'MODULEWorkInstaller', 51 | 'modxevo' => 'MODXEvoInstaller', 52 | 'moodle' => 'MoodleInstaller', 53 | 'october' => 'OctoberInstaller', 54 | 'oxid' => 'OxidInstaller', 55 | 'phpbb' => 'PhpBBInstaller', 56 | 'pimcore' => 'PimcoreInstaller', 57 | 'piwik' => 'PiwikInstaller', 58 | 'ppi' => 'PPIInstaller', 59 | 'puppet' => 'PuppetInstaller', 60 | 'redaxo' => 'RedaxoInstaller', 61 | 'roundcube' => 'RoundcubeInstaller', 62 | 'shopware' => 'ShopwareInstaller', 63 | 'silverstripe' => 'SilverStripeInstaller', 64 | 'smf' => 'SMFInstaller', 65 | 'symfony1' => 'Symfony1Installer', 66 | 'thelia' => 'TheliaInstaller', 67 | 'tusk' => 'TuskInstaller', 68 | 'typo3-cms' => 'TYPO3CmsInstaller', 69 | 'typo3-flow' => 'TYPO3FlowInstaller', 70 | 'whmcs' => 'WHMCSInstaller', 71 | 'wolfcms' => 'WolfCMSInstaller', 72 | 'wordpress' => 'WordPressInstaller', 73 | 'zend' => 'ZendInstaller', 74 | 'zikula' => 'ZikulaInstaller', 75 | 'prestashop' => 'PrestashopInstaller' 76 | ); 77 | 78 | /** 79 | * {@inheritDoc} 80 | */ 81 | public function getInstallPath(PackageInterface $package) 82 | { 83 | $type = $package->getType(); 84 | $frameworkType = $this->findFrameworkType($type); 85 | 86 | if ($frameworkType === false) { 87 | throw new \InvalidArgumentException( 88 | 'Sorry the package type of this package is not yet supported.' 89 | ); 90 | } 91 | 92 | $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 93 | $installer = new $class($package, $this->composer, $this->getIO()); 94 | 95 | return $installer->getInstallPath($package, $frameworkType); 96 | } 97 | 98 | public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) 99 | { 100 | if (!$repo->hasPackage($package)) { 101 | throw new \InvalidArgumentException('Package is not installed: '.$package); 102 | } 103 | 104 | $repo->removePackage($package); 105 | 106 | $installPath = $this->getInstallPath($package); 107 | $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? 'deleted' : 'not deleted')); 108 | } 109 | 110 | /** 111 | * {@inheritDoc} 112 | */ 113 | public function supports($packageType) 114 | { 115 | $frameworkType = $this->findFrameworkType($packageType); 116 | 117 | if ($frameworkType === false) { 118 | return false; 119 | } 120 | 121 | $locationPattern = $this->getLocationPattern($frameworkType); 122 | 123 | return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; 124 | } 125 | 126 | /** 127 | * Finds a supported framework type if it exists and returns it 128 | * 129 | * @param string $type 130 | * @return string 131 | */ 132 | protected function findFrameworkType($type) 133 | { 134 | $frameworkType = false; 135 | 136 | krsort($this->supportedTypes); 137 | 138 | foreach ($this->supportedTypes as $key => $val) { 139 | if ($key === substr($type, 0, strlen($key))) { 140 | $frameworkType = substr($type, 0, strlen($key)); 141 | break; 142 | } 143 | } 144 | 145 | return $frameworkType; 146 | } 147 | 148 | /** 149 | * Get the second part of the regular expression to check for support of a 150 | * package type 151 | * 152 | * @param string $frameworkType 153 | * @return string 154 | */ 155 | protected function getLocationPattern($frameworkType) 156 | { 157 | $pattern = false; 158 | if (!empty($this->supportedTypes[$frameworkType])) { 159 | $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; 160 | /** @var BaseInstaller $framework */ 161 | $framework = new $frameworkClass(null, $this->composer, $this->getIO()); 162 | $locations = array_keys($framework->getLocations()); 163 | $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; 164 | } 165 | 166 | return $pattern ? : '(\w+)'; 167 | } 168 | 169 | /** 170 | * Get I/O object 171 | * 172 | * @return IOInterface 173 | */ 174 | private function getIO() 175 | { 176 | return $this->io; 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/Pluralise.php: -------------------------------------------------------------------------------- 1 | "$1zes", 14 | '/^(ox)$/i' => "$1en", 15 | '/([m|l])ouse$/i' => "$1ice", 16 | '/(matrix|vertex|index)$/i'=> "$1ices", 17 | '/(x|ch|ss|sh)$/i' => "$1es", 18 | '/([^aeiouy]|qu)y$/i' => "$1ies", 19 | '/(hive)$/i' => "$1s", 20 | '/(?:([^f])fe|([lr])f)$/i' => "$1$2ves", 21 | '/(shea|lea|loa|thie)f$/i' => "$1ves", 22 | '/sis$/i' => "ses", 23 | '/([ti])um$/i' => "$1a", 24 | '/(tomat|potat|ech|her|vet)o$/i'=> "$1oes", 25 | '/(bu)s$/i' => "$1ses", 26 | '/(alias)$/i' => "$1es", 27 | '/(octop)us$/i' => "$1i", 28 | '/(ax|test)is$/i' => "$1es", 29 | '/(us)$/i' => "$1es", 30 | '/s$/i' => "s" 31 | ); 32 | 33 | private static $singular = array( 34 | '/(quiz)zes$/i' => "$1", 35 | '/(matr)ices$/i' => "$1ix", 36 | '/(vert|ind)ices$/i' => "$1ex", 37 | '/^(ox)en$/i' => "$1", 38 | '/(alias)es$/i' => "$1", 39 | '/(octop|vir)i$/i' => "$1us", 40 | '/(cris|ax|test)es$/i' => "$1is", 41 | '/(shoe)s$/i' => "$1", 42 | '/(o)es$/i' => "$1", 43 | '/(bus)es$/i' => "$1", 44 | '/([m|l])ice$/i' => "$1ouse", 45 | '/(x|ch|ss|sh)es$/i' => "$1", 46 | '/(m)ovies$/i' => "$1ovie", 47 | '/(s)eries$/i' => "$1eries", 48 | '/([^aeiouy]|qu)ies$/i' => "$1y", 49 | '/([lr])ves$/i' => "$1f", 50 | '/(tive)s$/i' => "$1", 51 | '/(hive)s$/i' => "$1", 52 | '/(li|wi|kni)ves$/i' => "$1fe", 53 | '/(shea|loa|lea|thie)ves$/i'=> "$1f", 54 | '/(^analy)ses$/i' => "$1sis", 55 | '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis", 56 | '/([ti])a$/i' => "$1um", 57 | '/(n)ews$/i' => "$1ews", 58 | '/(h|bl)ouses$/i' => "$1ouse", 59 | '/(corpse)s$/i' => "$1", 60 | '/(us)es$/i' => "$1", 61 | '/s$/i' => "" 62 | ); 63 | 64 | private static $irregular = array( 65 | 'child' => 'children', 66 | 'foot' => 'feet', 67 | 'goose' => 'geese', 68 | 'man' => 'men', 69 | 'mouse' => 'mice', 70 | 'move' => 'moves', 71 | 'person' => 'people', 72 | 'sex' => 'sexes', 73 | 'tooth' => 'teeth', 74 | ); 75 | 76 | // Some words are only uncountable sometimes. For example, "blues" can be 77 | // uncountable when referring to music, but countable when referring to 78 | // multiple colours. 79 | private static $uncountable = array( 80 | 'beef', 81 | 'bison', 82 | 'buffalo', 83 | 'carbon', 84 | 'chemistry', 85 | 'copper', 86 | 'geometry', 87 | 'gold', 88 | 'cs', 89 | 'css', 90 | 'deer', 91 | 'equipment', 92 | 'fish', 93 | 'furniture', 94 | 'information', 95 | 'mathematics', 96 | 'money', 97 | 'moose', 98 | 'nitrogen', 99 | 'oxygen', 100 | 'rice', 101 | 'series', 102 | 'sheep', 103 | 'species', 104 | 'surgery', 105 | 'traffic', 106 | 'water' 107 | ); 108 | 109 | /** 110 | * Get the plural of the word passed in. 111 | * @param string $string Word to pluralise 112 | * @return string Pluralised word 113 | */ 114 | public static function getPlural($string) 115 | { 116 | // save some time in the case that singular and plural are the same 117 | if (in_array(strtolower($string), self::$uncountable)) { 118 | return $string; 119 | } 120 | 121 | // check to see if already plural and irregular 122 | foreach (self::$irregular as $pattern => $result) { 123 | $_pattern = '/' . $result . '$/i'; 124 | if (preg_match($_pattern, $string)) { 125 | return $string; 126 | } 127 | } 128 | 129 | // check for irregular singular forms 130 | foreach (self::$irregular as $pattern => $result) { 131 | $pattern = '/' . $pattern . '$/i'; 132 | if (preg_match($pattern, $string)) { 133 | return preg_replace($pattern, $result, $string); 134 | } 135 | } 136 | 137 | // check for matches using regular expressions 138 | foreach (self::$plural as $pattern => $result) { 139 | if (preg_match($pattern, $string)) { 140 | return preg_replace($pattern, $result, $string); 141 | } 142 | } 143 | 144 | // No pattern match. Add an "s". 145 | return $string . 's'; 146 | } 147 | 148 | /** 149 | * Get the singular of the word passed in. 150 | * @param string $string Word to singularise 151 | * @return string Singularised word 152 | */ 153 | public static function getSingular($string) 154 | { 155 | // save some time in the case that singular and plural are the same 156 | if (in_array(strtolower($string), self::$uncountable)) { 157 | return $string; 158 | } 159 | 160 | // check to see if already singular and irregular 161 | foreach (self::$irregular as $pattern => $result) { 162 | $_pattern = '/' . $pattern . '$/i'; 163 | if (preg_match($_pattern, $string)) { 164 | return $string; 165 | } 166 | } 167 | 168 | // check for irregular plural forms 169 | foreach (self::$irregular as $result => $pattern) { 170 | $pattern = '/' . $pattern . '$/i'; 171 | if (preg_match($pattern, $string)) { 172 | return preg_replace($pattern, $result, $string); 173 | } 174 | } 175 | 176 | // check for matches using regular expressions 177 | foreach (self::$singular as $pattern => $result) { 178 | if (preg_match($pattern, $string)) { 179 | return preg_replace($pattern, $result, $string); 180 | } 181 | } 182 | 183 | return $string; 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/Maths.php: -------------------------------------------------------------------------------- 1 | $max) { 26 | $score = $max; 27 | } elseif ($score < $min) { 28 | $score = $min; 29 | } 30 | $score = self::bcCalc($score, '+', 0, true, $dps); // Round 31 | 32 | return $score; 33 | } 34 | 35 | /** 36 | * Do simple reliable floating point calculations without the risk of wrong results 37 | * @see http://floating-point-gui.de/ 38 | * @see the big red warning on http://php.net/language.types.float.php 39 | * 40 | * @source https://gist.github.com/jrfnl/8449978 41 | * 42 | * In the rare case that the bcmath extension would not be loaded, it will return the normal calculation results 43 | * 44 | * @param mixed $number1 Scalar (string/int/float/bool) 45 | * @param string $action Calculation action to execute. Valid input: 46 | * '+' or 'add' or 'addition', 47 | * '-' or 'sub' or 'subtract', 48 | * '*' or 'mul' or 'multiply', 49 | * '/' or 'div' or 'divide', 50 | * '%' or 'mod' or 'modulus' 51 | * '=' or 'comp' or 'compare' 52 | * @param mixed $number2 Scalar (string/int/float/bool) 53 | * @param bool $round Whether or not to round the result. Defaults to false. 54 | * Will be disregarded for a compare operation 55 | * @param int $decimals Decimals for rounding operation. Defaults to 0. 56 | * @param int $precision Calculation precision. Defaults to 10. 57 | * @return mixed Calculation result or false if either or the numbers isn't scalar or 58 | * an invalid operation was passed 59 | * - for compare the result will always be an integer 60 | * - for all other operations, the result will either be an integer 61 | * (preferred) or a float 62 | */ 63 | public static function bcCalc($number1, $action, $number2, $round = false, $decimals = 0, $precision = 10) 64 | { 65 | if (!is_scalar($number1) || !is_scalar($number2)) { 66 | return false; 67 | } 68 | 69 | // Check whether bcmath extension is available 70 | if (is_null(self::$blnBcmath)) { 71 | self::$blnBcmath = extension_loaded('bcmath'); 72 | } 73 | 74 | // Check values of input variables 75 | if (self::$blnBcmath) { 76 | $number1 = strval($number1); 77 | $number2 = strval($number2); 78 | } 79 | 80 | // Normalise operator 81 | $action = self::normaliseOperator($action); 82 | 83 | // Perform calculation 84 | return self::performCalc($number1, $action, $number2, $round, $decimals, $precision); 85 | } 86 | 87 | /** 88 | * Normalise operators for bcMath function. 89 | * @param string $operator Operators such as "+", "add" 90 | * @return string 91 | */ 92 | public static function normaliseOperator($operator) 93 | { 94 | switch ($operator) { 95 | case 'add': 96 | case 'addition': 97 | $operator = '+'; 98 | break; 99 | case 'sub': 100 | case 'subtract': 101 | $operator = '-'; 102 | break; 103 | case 'mul': 104 | case 'multiply': 105 | $operator = '*'; 106 | break; 107 | case 'div': 108 | case 'divide': 109 | $operator = '/'; 110 | break; 111 | case 'mod': 112 | case 'modulus': 113 | $operator = '%'; 114 | break; 115 | case 'comp': 116 | case 'compare': 117 | $operator = '='; 118 | break; 119 | } 120 | return $operator; 121 | } 122 | 123 | /** 124 | * Function which performs calculation. 125 | * @param string|integer|float|boolean $number1 See bcCalc description 126 | * @param string $action See bcCalc description 127 | * @param string|integer|float|boolean $number2 See bcCalc description 128 | * @param boolean $round See bcCalc description 129 | * @param integer $decimals See bcCalc description 130 | * @param integer $precision See bcCalc description 131 | * @return integer|float|boolean 132 | */ 133 | private static function performCalc($number1, $action, $number2, $round, $decimals, $precision) 134 | { 135 | $result = null; 136 | $compare = false; 137 | switch ($action) { 138 | case '+': 139 | $result = (self::$blnBcmath) ? bcadd($number1, $number2, $precision) /* string */ : ($number1 + $number2); 140 | break; 141 | case '-': 142 | $result = (self::$blnBcmath) ? bcsub($number1, $number2, $precision) /* string */ : ($number1 - $number2); 143 | break; 144 | case '*': 145 | $result = (self::$blnBcmath) ? bcmul($number1, $number2, $precision) /* string */ : ($number1 * $number2); 146 | break; 147 | case 'sqrt': 148 | $result = (self::$blnBcmath) ? bcsqrt($number1, $precision) /* string */ : sqrt($number1); 149 | break; 150 | case '/': 151 | if ($number2 > 0) { 152 | if (self::$blnBcmath) { 153 | $result = bcdiv($number1, $number2, $precision); // string, or NULL if right_operand is 0 154 | } else if ($number2 != 0) { 155 | $result = $number1 / $number2; 156 | } 157 | } 158 | 159 | if (!isset($result)) { 160 | $result = 0; 161 | } 162 | break; 163 | case '%': 164 | if (self::$blnBcmath) { 165 | $result = bcmod($number1, $number2); // string, or NULL if modulus is 0. 166 | } else if ($number2 != 0) { 167 | $result = $number1 % $number2; 168 | } 169 | 170 | if (!isset($result)) { 171 | $result = 0; 172 | } 173 | break; 174 | case '=': 175 | $compare = true; 176 | if (self::$blnBcmath) { 177 | $result = bccomp($number1, $number2, $precision); // returns int 0, 1 or -1 178 | } else { 179 | $result = ($number1 == $number2) ? 0 : (($number1 > $number2) ? 1 : -1); 180 | } 181 | break; 182 | } 183 | 184 | if (isset($result)) { 185 | if ($compare === false) { 186 | if ($round === true) { 187 | $result = round(floatval($result), $decimals); 188 | if ($decimals === 0) { 189 | $result = (int) $result; 190 | } 191 | } else { 192 | $result = (intval($result) == $result) ? intval($result) : floatval($result); 193 | } 194 | } 195 | return $result; 196 | } 197 | 198 | return false; 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /vendor/composer/installers/README.md: -------------------------------------------------------------------------------- 1 | # A Multi-Framework [Composer](http://getcomposer.org) Library Installer 2 | 3 | [![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers) 4 | 5 | This is for PHP package authors to require in their `composer.json`. It will 6 | install their package to the correct location based on the specified package 7 | type. 8 | 9 | The goal of `installers` is to be a simple package type to install path map. 10 | Users can also customize the install path per package and package authors can 11 | modify the package name upon installing. 12 | 13 | `installers` isn't intended on replacing all custom installers. If your 14 | package requires special installation handling then by all means, create a 15 | custom installer to handle it. 16 | 17 | **Natively Supported Frameworks**: 18 | 19 | The following frameworks natively work with Composer and will be 20 | installed to the default `vendor` directory. `composer/installers` 21 | is not needed to install packages with these frameworks: 22 | 23 | * Aura 24 | * Symfony2 25 | * Yii 26 | * Yii2 27 | 28 | **Current Supported Package Types**: 29 | 30 | > Stable types are marked as **bold**, this means that installation paths 31 | > for those type will not be changed. Any adjustment for those types would 32 | > require creation of brand new type that will cover required changes. 33 | 34 | | Framework | Types 35 | | --------- | ----- 36 | | Aimeos | `aimeos-extension` 37 | | Asgard | `asgard-module`
`asgard-theme` 38 | | AGL | `agl-module` 39 | | Bonefish | `bonefish-package` 40 | | AnnotateCms | `annotatecms-module`
`annotatecms-component`
`annotatecms-service` 41 | | Bitrix | `bitrix-module`
`bitrix-component`
`bitrix-theme` 42 | | CakePHP 2+ | **`cakephp-plugin`** 43 | | Chef | `chef-cookbook`
`chef-role` 44 | | CCFramework | `ccframework-ship`
`ccframework-theme` 45 | | CodeIgniter | `codeigniter-library`
`codeigniter-third-party`
`codeigniter-module` 46 | | concrete5 | `concrete5-block`
`concrete5-package`
`concrete5-theme`
`concrete5-update` 47 | | Craft | `craft-plugin` 48 | | Croogo | `croogo-plugin`
`croogo-theme` 49 | | DokuWiki | `dokuwiki-plugin`
`dokuwiki-template` 50 | | Dolibarr | `dolibarr-module` 51 | | Drupal | `drupal-core`
`drupal-module`
`drupal-theme`

`drupal-library`
`drupal-profile`
`drupal-drush` 52 | | Elgg | `elgg-plugin` 53 | | FuelPHP v1.x | `fuel-module`
`fuel-package`
`fuel-theme` 54 | | FuelPHP v2.x | `fuelphp-component` 55 | | Grav | `grav-plugin`
`grav-theme` 56 | | Hurad | `hurad-plugin`
`hurad-theme` 57 | | ImageCMS | `imagecms-template`
`imagecms-module`
`imagecms-library` 58 | | Joomla | `joomla-component`
`joomla-module`
`joomla-template`
`joomla-plugin`
`joomla-library` 59 | | Kirby | **`kirby-plugin`**
`kirby-field`
`kirby-tag` 60 | | KodiCMS | `kodicms-plugin`
`kodicms-media` 61 | | Kohana | **`kohana-module`** 62 | | Laravel | `laravel-library` 63 | | Lithium | **`lithium-library`
`lithium-source`** 64 | | Magento | `magento-library`
`magento-skin`
`magento-theme` 65 | | Mako | `mako-package` 66 | | Mautic | `mautic-plugin`
`mautic-theme` 67 | | MODX Evo | `modxevo-snippet`
`modxevo-plugin`
`modxevo-module`
`modxevo-template`
`modxevo-lib` 68 | | MediaWiki | `mediawiki-extension` 69 | | October | **`october-module`
`october-plugin`
`october-theme`** 70 | | OXID | `oxid-module`
`oxid-theme`
`oxid-out` 71 | | MODULEWork | `modulework-module` 72 | | Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types) 73 | | Piwik | `piwik-plugin` 74 | | phpBB | `phpbb-extension`
`phpbb-style`
`phpbb-language` 75 | | Pimcore | `pimcore-plugin` 76 | | PPI | **`ppi-module`** 77 | | Puppet | `puppet-module` 78 | | REDAXO | `redaxo-addon` 79 | | Roundcube | `roundcube-plugin` 80 | | shopware | `shopware-backend-plugin`
`shopware-core-plugin`
`shopware-frontend-plugin`
`shopware-theme` 81 | | SilverStripe | `silverstripe-module`
`silverstripe-theme` 82 | | SMF | `smf-module`
`smf-theme` 83 | | symfony1 | **`symfony1-plugin`** 84 | | Tusk | `tusk-task`
`tusk-command`
`tusk-asset` 85 | | TYPO3 Flow | `typo3-flow-package`
`typo3-flow-framework`
`typo3-flow-plugin`
`typo3-flow-site`
`typo3-flow-boilerplate`
`typo3-flow-build` 86 | | TYPO3 CMS | `typo3-cms-extension` (Deprecated in this package, use the [TYPO3 CMS Installers](https://packagist.org/packages/typo3/cms-composer-installers) instead) 87 | | Wolf CMS | `wolfcms-plugin` 88 | | WordPress | `wordpress-plugin`
`wordpress-theme`

`wordpress-muplugin` 89 | | Zend | `zend-library`
`zend-extra`
`zend-module` 90 | | Zikula | `zikula-module`
`zikula-theme` 91 | | Prestashop | `prestashop-module`
`prestashop-theme` 92 | 93 | ## Example `composer.json` File 94 | 95 | This is an example for a CakePHP plugin. The only important parts to set in your 96 | composer.json file are `"type": "cakephp-plugin"` which describes what your 97 | package is and `"require": { "composer/installers": "~1.0" }` which tells composer 98 | to load the custom installers. 99 | 100 | ```json 101 | { 102 | "name": "you/ftp", 103 | "type": "cakephp-plugin", 104 | "require": { 105 | "composer/installers": "~1.0" 106 | } 107 | } 108 | ``` 109 | 110 | This would install your package to the `Plugin/Ftp/` folder of a CakePHP app 111 | when a user runs `php composer.phar install`. 112 | 113 | So submit your packages to [packagist.org](http://packagist.org)! 114 | 115 | ## Custom Install Paths 116 | 117 | If you are consuming a package that uses the `composer/installers` you can 118 | override the install path with the following extra in your `composer.json`: 119 | 120 | ```json 121 | { 122 | "extra": { 123 | "installer-paths": { 124 | "your/custom/path/{$name}/": ["shama/ftp", "vendor/package"] 125 | } 126 | } 127 | } 128 | ``` 129 | 130 | A package type can have a custom installation path with a `type:` prefix. 131 | 132 | ``` json 133 | { 134 | "extra": { 135 | "installer-paths": { 136 | "your/custom/path/{$name}/": ["type:wordpress-plugin"] 137 | } 138 | } 139 | } 140 | ``` 141 | 142 | You can also have the same vendor packages with a custom installation path by 143 | using the `vendor:` prefix. 144 | 145 | ``` json 146 | { 147 | "extra": { 148 | "installer-paths": { 149 | "your/custom/path/{$name}/": ["vendor:my_organization"] 150 | } 151 | } 152 | } 153 | ``` 154 | 155 | These would use your custom path for each of the listed packages. The available 156 | variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`. 157 | 158 | ## Custom Install Names 159 | 160 | If you're a package author and need your package to be named differently when 161 | installed consider using the `installer-name` extra. 162 | 163 | For example you have a package named `shama/cakephp-ftp` with the type 164 | `cakephp-plugin`. Installing with `composer/installers` would install to the 165 | path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a 166 | package author actually need the package to be named and installed to 167 | `Plugin/Ftp`. Using the following config within your **package** `composer.json` 168 | will allow this: 169 | 170 | ```json 171 | { 172 | "name": "shama/cakephp-ftp", 173 | "type": "cakephp-plugin", 174 | "extra": { 175 | "installer-name": "Ftp" 176 | } 177 | } 178 | ``` 179 | 180 | Please note the name entered into `installer-name` will be the final and will 181 | not be inflected. 182 | 183 | ## Contribute! 184 | 185 | * [Fork and clone](https://help.github.com/articles/fork-a-repo). 186 | * Run the command `php composer.phar install` to install the dependencies. 187 | This will also install the dev dependencies. See [Composer](https://getcomposer.org/doc/03-cli.md#install). 188 | * Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de). 189 | * Create a branch, commit, push and send us a 190 | [pull request](https://help.github.com/articles/using-pull-requests). 191 | 192 | To ensure a consistent code base, you should make sure the code follows the 193 | [Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html) 194 | which we borrowed from Symfony. 195 | 196 | If you would like to help, please take a look at the list of 197 | [issues](https://github.com/composer/installers/issues). 198 | 199 | ### Should we allow dynamic package types or paths? No. 200 | What are they? The ability for a package author to determine where a package 201 | will be installed either through setting the path directly in their 202 | `composer.json` or through a dynamic package type: `"type": 203 | "framework-install-here"`. 204 | 205 | It has been proposed many times. Even implemented once early on and then 206 | removed. `installers` won't do this because it would allow a single package 207 | author to wipe out entire folders without the user's consent. That user would 208 | then come here to yell at us. 209 | 210 | Anyone still wanting this capability should consider requiring https://github.com/oomphinc/composer-installers-extender. 211 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/Text.php: -------------------------------------------------------------------------------- 1 | (.*?)`is', '', $strText); 91 | $strText = preg_replace('`\]*>`is', '.', $strText); 92 | $strText = html_entity_decode($strText); 93 | $strText = strip_tags($strText); 94 | 95 | // Assume blank lines (i.e., paragraph breaks) end sentences (useful 96 | // for titles in plain text documents) and replace remaining new 97 | // lines with spaces 98 | $strText = preg_replace('`(\r\n|\n\r)`is', "\n", $strText); 99 | $strText = preg_replace('`(\r|\n){2,}`is', ".\n\n", $strText); 100 | $strText = preg_replace('`[ ]*(\n|\r\n|\r)[ ]*`', ' ', $strText); 101 | 102 | // Replace commas, hyphens, quotes etc (count as spaces) 103 | $strText = preg_replace('`[",:;()/\`-]`', ' ', $strText); 104 | 105 | // Unify terminators and spaces 106 | $strText = trim($strText, '. ') . '.'; // Add final terminator. 107 | $strText = preg_replace('`[\.!?]`', '.', $strText); // Unify terminators 108 | $strText = preg_replace('`([\.\s]*\.[\.\s]*)`mis', '. ', $strText); // Merge terminators separated by whitespace. 109 | $strText = preg_replace('`[ ]+`', ' ', $strText); // Remove multiple spaces 110 | $strText = preg_replace('`([\.])[\. ]+`', '$1', $strText); // Check for duplicated terminators 111 | $strText = trim(preg_replace('`[ ]*([\.])`', '$1 ', $strText)); // Pad sentence terminators 112 | 113 | // Lower case all words following terminators (for gunning fog score) 114 | $strText = preg_replace_callback('`\. [^\. ]`', create_function('$matches', 'return strtolower($matches[0]);'), $strText); 115 | 116 | $strText = trim($strText); 117 | 118 | // Cache it and return 119 | self::$clean[$key] = $strText; 120 | return $strText; 121 | } 122 | 123 | /** 124 | * Converts string to lower case. Tries mb_strtolower and if that fails uses regular strtolower. 125 | * @param string $strText Text to be transformed 126 | * @param string $strEncoding Encoding of text 127 | * @return string 128 | */ 129 | public static function lowerCase($strText, $strEncoding = '') 130 | { 131 | 132 | if (is_null(self::$blnMbstring)) { 133 | self::$blnMbstring = extension_loaded('mbstring'); 134 | } 135 | 136 | if (!self::$blnMbstring) { 137 | $strLowerCaseText = strtolower($strText); 138 | } else { 139 | if ($strEncoding == '') { 140 | $strLowerCaseText = mb_strtolower($strText); 141 | } else { 142 | $strLowerCaseText = mb_strtolower($strText, $strEncoding); 143 | } 144 | } 145 | 146 | return $strLowerCaseText; 147 | } 148 | 149 | /** 150 | * Converts string to upper case. Tries mb_strtoupper and if that fails uses regular strtoupper. 151 | * @param string $strText Text to be transformed 152 | * @param string $strEncoding Encoding of text 153 | * @return string 154 | */ 155 | public static function upperCase($strText, $strEncoding = '') 156 | { 157 | 158 | if (is_null(self::$blnMbstring)) { 159 | self::$blnMbstring = extension_loaded('mbstring'); 160 | } 161 | 162 | if (!self::$blnMbstring) { 163 | $strUpperCaseText = strtoupper($strText); 164 | } else { 165 | if ($strEncoding == '') { 166 | $strUpperCaseText = mb_strtoupper($strText); 167 | } else { 168 | $strUpperCaseText = mb_strtoupper($strText, $strEncoding); 169 | } 170 | } 171 | 172 | return $strUpperCaseText; 173 | } 174 | 175 | /** 176 | * Gets portion of string. Tries mb_substr and if that fails uses regular substr. 177 | * @param string $strText Text to be cut up 178 | * @param int $intStart Start character 179 | * @param int $intLength Length 180 | * @param string $strEncoding Encoding of text 181 | * @return string 182 | */ 183 | public static function substring($strText, $intStart, $intLength, $strEncoding = '') 184 | { 185 | 186 | if (is_null(self::$blnMbstring)) { 187 | self::$blnMbstring = extension_loaded('mbstring'); 188 | } 189 | 190 | if (!self::$blnMbstring) { 191 | $strSubstring = substr($strText, $intStart, $intLength); 192 | } else { 193 | if ($strEncoding == '') { 194 | $strSubstring = mb_substr($strText, $intStart, $intLength); 195 | } else { 196 | $strSubstring = mb_substr($strText, $intStart, $intLength, $strEncoding); 197 | } 198 | } 199 | 200 | return $strSubstring; 201 | } 202 | 203 | /** 204 | * Gives string length. Tries mb_strlen and if that fails uses regular strlen. 205 | * @param string $strText Text to be measured 206 | * @param string $strEncoding Encoding of text 207 | * @return int 208 | */ 209 | public static function textLength($strText, $strEncoding = '') 210 | { 211 | 212 | if (is_null(self::$blnMbstring)) { 213 | self::$blnMbstring = extension_loaded('mbstring'); 214 | } 215 | 216 | if (!self::$blnMbstring) { 217 | $intTextLength = strlen($strText); 218 | } else { 219 | if ($strEncoding == '') { 220 | $intTextLength = mb_strlen($strText); 221 | } else { 222 | $intTextLength = mb_strlen($strText, $strEncoding); 223 | } 224 | } 225 | 226 | return $intTextLength; 227 | } 228 | 229 | /** 230 | * Alias for textLength, as "letterCount", "wordCount" etc also used 231 | * @param string $strText Text to be measured 232 | * @param string $strEncoding Encoding of text 233 | * @return int 234 | */ 235 | public static function characterCount($strText, $strEncoding = '') 236 | { 237 | return self::textLength($strText, $strEncoding); 238 | } 239 | 240 | /** 241 | * Gives letter count (ignores all non-letters). Tries mb_strlen and if 242 | * that fails uses regular strlen. 243 | * @param string $strText Text to be measured 244 | * @param string $strEncoding Encoding of text 245 | * @return int 246 | */ 247 | public static function letterCount($strText, $strEncoding = '') 248 | { 249 | if (strlen(trim($strText)) == 0) { 250 | return 0; 251 | } 252 | 253 | if (is_null(self::$blnMbstring)) { 254 | self::$blnMbstring = extension_loaded('mbstring'); 255 | } 256 | 257 | $strText = self::cleanText($strText); // To clear out newlines etc 258 | $intTextLength = 0; 259 | $strText = preg_replace('`[^A-Za-z]+`', '', $strText); 260 | try { 261 | 262 | if (!self::$blnMbstring) { 263 | throw new Exception('The extension mbstring is not loaded.'); 264 | } 265 | 266 | if ($strEncoding == '') { 267 | $intTextLength = mb_strlen($strText); 268 | } else { 269 | $intTextLength = mb_strlen($strText, $strEncoding); 270 | } 271 | } catch (\Exception $e) { 272 | $intTextLength = strlen($strText); 273 | } 274 | 275 | return $intTextLength; 276 | } 277 | 278 | /** 279 | * Returns word count for text. 280 | * @param string $strText Text to be measured 281 | * @param string $strEncoding Encoding of text 282 | * @return int 283 | */ 284 | public static function wordCount($strText, $strEncoding = '') 285 | { 286 | if (strlen(trim($strText)) == 0) { 287 | return 0; 288 | } 289 | 290 | // Will be tripped by em dashes with spaces either side, among other similar characters 291 | $intWords = 1 + self::textLength(preg_replace('`[^ ]`', '', $strText), $strEncoding); // Space count + 1 is word count 292 | 293 | return $intWords; 294 | } 295 | 296 | /** 297 | * Returns sentence count for text. 298 | * @param string $strText Text to be measured 299 | * @param string $strEncoding Encoding of text 300 | * @return int 301 | */ 302 | public static function sentenceCount($strText, $strEncoding = '') 303 | { 304 | if (strlen(trim($strText)) == 0) { 305 | return 0; 306 | } 307 | 308 | // Will be tripped up by "Mr." or "U.K.". Not a major concern at this point. 309 | $intSentences = max(1, self::textLength(preg_replace('`[^\.!?]`', '', $strText), $strEncoding)); 310 | 311 | return $intSentences; 312 | } 313 | 314 | /** 315 | * Returns average words per sentence for text. 316 | * @param string $strText Text to be measured 317 | * @param string $strEncoding Encoding of text 318 | * @return int|float 319 | */ 320 | public static function averageWordsPerSentence($strText, $strEncoding = '') 321 | { 322 | $intSentenceCount = self::sentenceCount($strText, $strEncoding); 323 | $intWordCount = self::wordCount($strText, $strEncoding); 324 | 325 | $averageWords = (Maths::bcCalc($intWordCount, '/', $intSentenceCount)); 326 | return $averageWords; 327 | } 328 | } 329 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/tests/TextStatisticsMaths.php: -------------------------------------------------------------------------------- 1 | TextStatistics = new DaveChild\TextStatistics\TextStatistics(); 19 | $this->TextStatistics->normalise = false; 20 | } 21 | 22 | public function tearDown() 23 | { 24 | unset($this->objTextStatistics); 25 | } 26 | 27 | /* Test Normalisation 28 | -------------------- */ 29 | public function testNormalisation() 30 | { 31 | // Maths::normaliseScore($score, $min, $max, $dps = 1) 32 | $this->assertSame(3.1, DaveChild\TextStatistics\Maths::normaliseScore(3.141592654, 1, 10, 1)); 33 | $this->assertSame(10.0, DaveChild\TextStatistics\Maths::normaliseScore(13.141592654, 1, 10, 1)); 34 | $this->assertSame(1.0, DaveChild\TextStatistics\Maths::normaliseScore(-3.141592654, 1, 10, 1)); 35 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::normaliseScore(3, 1, 10, 1)); 36 | $this->assertSame(3, DaveChild\TextStatistics\Maths::normaliseScore(3.141592654, 1, 10, 0)); 37 | $this->assertSame(10, DaveChild\TextStatistics\Maths::normaliseScore(13.141592654, 1, 10, 0)); 38 | $this->assertSame(1, DaveChild\TextStatistics\Maths::normaliseScore(-3.141592654, 1, 10, 0)); 39 | $this->assertSame(3, DaveChild\TextStatistics\Maths::normaliseScore(3, 1, 10, 0)); 40 | } 41 | 42 | /* Test Normalisation 43 | -------------------- */ 44 | public function testCalc() 45 | { 46 | $this->assertSame(15.0, DaveChild\TextStatistics\Maths::bcCalc(10, '+', 5, true, 1)); 47 | $this->assertSame(15.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'add', 5, true, 1)); 48 | $this->assertSame(15.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'addition', 5, true, 1)); 49 | $this->assertSame(15.6, DaveChild\TextStatistics\Maths::bcCalc(10, '+', 5.55, true, 1)); 50 | $this->assertSame(15.6, DaveChild\TextStatistics\Maths::bcCalc(10, 'add', 5.55, true, 1)); 51 | $this->assertSame(15.6, DaveChild\TextStatistics\Maths::bcCalc(10, 'addition', 5.55, true, 1)); 52 | $this->assertSame(5.0, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5, true, 1)); 53 | $this->assertSame(5.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5, true, 1)); 54 | $this->assertSame(5.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5, true, 1)); 55 | $this->assertSame(4.5, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5.55, true, 1)); 56 | $this->assertSame(4.5, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5.55, true, 1)); 57 | $this->assertSame(4.5, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5.55, true, 1)); 58 | $this->assertSame(4.4, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5.56, true, 1)); 59 | $this->assertSame(4.4, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5.56, true, 1)); 60 | $this->assertSame(4.4, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5.56, true, 1)); 61 | $this->assertSame(50.0, DaveChild\TextStatistics\Maths::bcCalc(10, '*', 5, true, 1)); 62 | $this->assertSame(50.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mul', 5, true, 1)); 63 | $this->assertSame(50.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'multiply', 5, true, 1)); 64 | $this->assertSame(55.6, DaveChild\TextStatistics\Maths::bcCalc(10, '*', 5.555, true, 1)); 65 | $this->assertSame(55.6, DaveChild\TextStatistics\Maths::bcCalc(10, 'mul', 5.555, true, 1)); 66 | $this->assertSame(55.6, DaveChild\TextStatistics\Maths::bcCalc(10, 'multiply', 5.555, true, 1)); 67 | $this->assertSame(2.0, DaveChild\TextStatistics\Maths::bcCalc(10, '/', 5, true, 1)); 68 | $this->assertSame(2.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'div', 5, true, 1)); 69 | $this->assertSame(2.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'divide', 5, true, 1)); 70 | $this->assertSame(1.8, DaveChild\TextStatistics\Maths::bcCalc(10, '/', 5.5, true, 1)); 71 | $this->assertSame(1.8, DaveChild\TextStatistics\Maths::bcCalc(10, 'div', 5.5, true, 1)); 72 | $this->assertSame(1.8, DaveChild\TextStatistics\Maths::bcCalc(10, 'divide', 5.5, true, 1)); 73 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(0, '/', 10, true, 1)); 74 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(0, 'div', 10, true, 1)); 75 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(0, 'divide', 10, true, 1)); 76 | 77 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 5, true, 1)); 78 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 5, true, 1)); 79 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 5, true, 1)); 80 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 7, true, 1)); 81 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 7, true, 1)); 82 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 7, true, 1)); 83 | // Modulus can only be an integer and is rounded before calculation 84 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 5.55, true, 1)); 85 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 5.55, true, 1)); 86 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 5.55, true, 1)); 87 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 7.55, true, 1)); 88 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 7.55, true, 1)); 89 | $this->assertSame(3.0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 7.55, true, 1)); 90 | 91 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, '=', 5, true, 1)); 92 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, 'comp', 5, true, 1)); 93 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, 'compare', 5, true, 1)); 94 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, '=', 10, true, 1)); 95 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'comp', 10, true, 1)); 96 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'compare', 10, true, 1)); 97 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, '=', 10, true, 1)); 98 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, 'comp', 10, true, 1)); 99 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, 'compare', 10, true, 1)); 100 | 101 | $this->assertSame(4.0, DaveChild\TextStatistics\Maths::bcCalc(16, 'sqrt', 5, true, 1)); 102 | $this->assertSame(3.9, DaveChild\TextStatistics\Maths::bcCalc(15, 'sqrt', 5, true, 1)); 103 | 104 | $this->assertSame(15, DaveChild\TextStatistics\Maths::bcCalc(10, '+', 5)); 105 | $this->assertSame(15, DaveChild\TextStatistics\Maths::bcCalc(10, 'add', 5)); 106 | $this->assertSame(15, DaveChild\TextStatistics\Maths::bcCalc(10, 'addition', 5)); 107 | $this->assertSame(15.55, DaveChild\TextStatistics\Maths::bcCalc(10, '+', 5.55)); 108 | $this->assertSame(15.55, DaveChild\TextStatistics\Maths::bcCalc(10, 'add', 5.55)); 109 | $this->assertSame(15.55, DaveChild\TextStatistics\Maths::bcCalc(10, 'addition', 5.55)); 110 | $this->assertSame(5, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5)); 111 | $this->assertSame(5, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5)); 112 | $this->assertSame(5, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5)); 113 | $this->assertSame(4.45, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5.55)); 114 | $this->assertSame(4.45, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5.55)); 115 | $this->assertSame(4.45, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5.55)); 116 | $this->assertSame(4.44, DaveChild\TextStatistics\Maths::bcCalc(10, '-', 5.56)); 117 | $this->assertSame(4.44, DaveChild\TextStatistics\Maths::bcCalc(10, 'sub', 5.56)); 118 | $this->assertSame(4.44, DaveChild\TextStatistics\Maths::bcCalc(10, 'subtract', 5.56)); 119 | $this->assertSame(50, DaveChild\TextStatistics\Maths::bcCalc(10, '*', 5)); 120 | $this->assertSame(50, DaveChild\TextStatistics\Maths::bcCalc(10, 'mul', 5)); 121 | $this->assertSame(50, DaveChild\TextStatistics\Maths::bcCalc(10, 'multiply', 5)); 122 | $this->assertSame(55.55, DaveChild\TextStatistics\Maths::bcCalc(10, '*', 5.555)); 123 | $this->assertSame(55.55, DaveChild\TextStatistics\Maths::bcCalc(10, 'mul', 5.555)); 124 | $this->assertSame(55.55, DaveChild\TextStatistics\Maths::bcCalc(10, 'multiply', 5.555)); 125 | $this->assertSame(2, DaveChild\TextStatistics\Maths::bcCalc(10, '/', 5)); 126 | $this->assertSame(2, DaveChild\TextStatistics\Maths::bcCalc(10, 'div', 5)); 127 | $this->assertSame(2, DaveChild\TextStatistics\Maths::bcCalc(10, 'divide', 5)); 128 | $this->assertSame(1.81818, DaveChild\TextStatistics\Maths::bcCalc(10, '/', 5.5, true, 5)); 129 | $this->assertSame(1.81818, DaveChild\TextStatistics\Maths::bcCalc(10, 'div', 5.5, true, 5)); 130 | $this->assertSame(1.81818, DaveChild\TextStatistics\Maths::bcCalc(10, 'divide', 5.5, true, 5)); 131 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(0, '/', 10)); 132 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(0, 'div', 10)); 133 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(0, 'divide', 10)); 134 | 135 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 5)); 136 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 5)); 137 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 5)); 138 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 7)); 139 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 7)); 140 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 7)); 141 | // Modulus can only be an integer and is rounded before calculation 142 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 5.55)); 143 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 5.55)); 144 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 5.55)); 145 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, '%', 7.55)); 146 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, 'mod', 7.55)); 147 | $this->assertSame(3, DaveChild\TextStatistics\Maths::bcCalc(10, 'modulus', 7.55)); 148 | 149 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, '=', 5)); 150 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, 'comp', 5)); 151 | $this->assertSame(1, DaveChild\TextStatistics\Maths::bcCalc(10, 'compare', 5)); 152 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, '=', 10)); 153 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'comp', 10)); 154 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc(10, 'compare', 10)); 155 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, '=', 10)); 156 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, 'comp', 10)); 157 | $this->assertSame(-1, DaveChild\TextStatistics\Maths::bcCalc(5, 'compare', 10)); 158 | 159 | $this->assertSame(4, DaveChild\TextStatistics\Maths::bcCalc(16, 'sqrt', 5)); 160 | $this->assertSame(3.87298, DaveChild\TextStatistics\Maths::bcCalc(15, 'sqrt', 5, true, 5)); 161 | 162 | // Malformed data 163 | $this->assertSame(false, DaveChild\TextStatistics\Maths::bcCalc(array('banana'), '+', 2, true, 1)); 164 | $this->assertSame(false, DaveChild\TextStatistics\Maths::bcCalc(2, '+', array('banana'), true, 1)); 165 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc('two', '+', 'three', true, 1)); 166 | $this->assertSame(0.0, DaveChild\TextStatistics\Maths::bcCalc('two', '/', 'three', true, 1)); 167 | $this->assertSame(false, DaveChild\TextStatistics\Maths::bcCalc(array('banana'), '+', 2)); 168 | $this->assertSame(false, DaveChild\TextStatistics\Maths::bcCalc(2, '+', array('banana'))); 169 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc('two', '+', 'three')); 170 | $this->assertSame(0, DaveChild\TextStatistics\Maths::bcCalc('two', '/', 'three')); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /vendor/composer/ClassLoader.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Composer\Autoload; 14 | 15 | /** 16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. 17 | * 18 | * $loader = new \Composer\Autoload\ClassLoader(); 19 | * 20 | * // register classes with namespaces 21 | * $loader->add('Symfony\Component', __DIR__.'/component'); 22 | * $loader->add('Symfony', __DIR__.'/framework'); 23 | * 24 | * // activate the autoloader 25 | * $loader->register(); 26 | * 27 | * // to enable searching the include path (eg. for PEAR packages) 28 | * $loader->setUseIncludePath(true); 29 | * 30 | * In this example, if you try to use a class in the Symfony\Component 31 | * namespace or one of its children (Symfony\Component\Console for instance), 32 | * the autoloader will first look for the class under the component/ 33 | * directory, and it will then fallback to the framework/ directory if not 34 | * found before giving up. 35 | * 36 | * This class is loosely based on the Symfony UniversalClassLoader. 37 | * 38 | * @author Fabien Potencier 39 | * @author Jordi Boggiano 40 | * @see http://www.php-fig.org/psr/psr-0/ 41 | * @see http://www.php-fig.org/psr/psr-4/ 42 | */ 43 | class ClassLoader 44 | { 45 | // PSR-4 46 | private $prefixLengthsPsr4 = array(); 47 | private $prefixDirsPsr4 = array(); 48 | private $fallbackDirsPsr4 = array(); 49 | 50 | // PSR-0 51 | private $prefixesPsr0 = array(); 52 | private $fallbackDirsPsr0 = array(); 53 | 54 | private $useIncludePath = false; 55 | private $classMap = array(); 56 | 57 | private $classMapAuthoritative = false; 58 | 59 | public function getPrefixes() 60 | { 61 | if (!empty($this->prefixesPsr0)) { 62 | return call_user_func_array('array_merge', $this->prefixesPsr0); 63 | } 64 | 65 | return array(); 66 | } 67 | 68 | public function getPrefixesPsr4() 69 | { 70 | return $this->prefixDirsPsr4; 71 | } 72 | 73 | public function getFallbackDirs() 74 | { 75 | return $this->fallbackDirsPsr0; 76 | } 77 | 78 | public function getFallbackDirsPsr4() 79 | { 80 | return $this->fallbackDirsPsr4; 81 | } 82 | 83 | public function getClassMap() 84 | { 85 | return $this->classMap; 86 | } 87 | 88 | /** 89 | * @param array $classMap Class to filename map 90 | */ 91 | public function addClassMap(array $classMap) 92 | { 93 | if ($this->classMap) { 94 | $this->classMap = array_merge($this->classMap, $classMap); 95 | } else { 96 | $this->classMap = $classMap; 97 | } 98 | } 99 | 100 | /** 101 | * Registers a set of PSR-0 directories for a given prefix, either 102 | * appending or prepending to the ones previously set for this prefix. 103 | * 104 | * @param string $prefix The prefix 105 | * @param array|string $paths The PSR-0 root directories 106 | * @param bool $prepend Whether to prepend the directories 107 | */ 108 | public function add($prefix, $paths, $prepend = false) 109 | { 110 | if (!$prefix) { 111 | if ($prepend) { 112 | $this->fallbackDirsPsr0 = array_merge( 113 | (array) $paths, 114 | $this->fallbackDirsPsr0 115 | ); 116 | } else { 117 | $this->fallbackDirsPsr0 = array_merge( 118 | $this->fallbackDirsPsr0, 119 | (array) $paths 120 | ); 121 | } 122 | 123 | return; 124 | } 125 | 126 | $first = $prefix[0]; 127 | if (!isset($this->prefixesPsr0[$first][$prefix])) { 128 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; 129 | 130 | return; 131 | } 132 | if ($prepend) { 133 | $this->prefixesPsr0[$first][$prefix] = array_merge( 134 | (array) $paths, 135 | $this->prefixesPsr0[$first][$prefix] 136 | ); 137 | } else { 138 | $this->prefixesPsr0[$first][$prefix] = array_merge( 139 | $this->prefixesPsr0[$first][$prefix], 140 | (array) $paths 141 | ); 142 | } 143 | } 144 | 145 | /** 146 | * Registers a set of PSR-4 directories for a given namespace, either 147 | * appending or prepending to the ones previously set for this namespace. 148 | * 149 | * @param string $prefix The prefix/namespace, with trailing '\\' 150 | * @param array|string $paths The PSR-4 base directories 151 | * @param bool $prepend Whether to prepend the directories 152 | * 153 | * @throws \InvalidArgumentException 154 | */ 155 | public function addPsr4($prefix, $paths, $prepend = false) 156 | { 157 | if (!$prefix) { 158 | // Register directories for the root namespace. 159 | if ($prepend) { 160 | $this->fallbackDirsPsr4 = array_merge( 161 | (array) $paths, 162 | $this->fallbackDirsPsr4 163 | ); 164 | } else { 165 | $this->fallbackDirsPsr4 = array_merge( 166 | $this->fallbackDirsPsr4, 167 | (array) $paths 168 | ); 169 | } 170 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) { 171 | // Register directories for a new namespace. 172 | $length = strlen($prefix); 173 | if ('\\' !== $prefix[$length - 1]) { 174 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 175 | } 176 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 177 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 178 | } elseif ($prepend) { 179 | // Prepend directories for an already registered namespace. 180 | $this->prefixDirsPsr4[$prefix] = array_merge( 181 | (array) $paths, 182 | $this->prefixDirsPsr4[$prefix] 183 | ); 184 | } else { 185 | // Append directories for an already registered namespace. 186 | $this->prefixDirsPsr4[$prefix] = array_merge( 187 | $this->prefixDirsPsr4[$prefix], 188 | (array) $paths 189 | ); 190 | } 191 | } 192 | 193 | /** 194 | * Registers a set of PSR-0 directories for a given prefix, 195 | * replacing any others previously set for this prefix. 196 | * 197 | * @param string $prefix The prefix 198 | * @param array|string $paths The PSR-0 base directories 199 | */ 200 | public function set($prefix, $paths) 201 | { 202 | if (!$prefix) { 203 | $this->fallbackDirsPsr0 = (array) $paths; 204 | } else { 205 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; 206 | } 207 | } 208 | 209 | /** 210 | * Registers a set of PSR-4 directories for a given namespace, 211 | * replacing any others previously set for this namespace. 212 | * 213 | * @param string $prefix The prefix/namespace, with trailing '\\' 214 | * @param array|string $paths The PSR-4 base directories 215 | * 216 | * @throws \InvalidArgumentException 217 | */ 218 | public function setPsr4($prefix, $paths) 219 | { 220 | if (!$prefix) { 221 | $this->fallbackDirsPsr4 = (array) $paths; 222 | } else { 223 | $length = strlen($prefix); 224 | if ('\\' !== $prefix[$length - 1]) { 225 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 226 | } 227 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 228 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 229 | } 230 | } 231 | 232 | /** 233 | * Turns on searching the include path for class files. 234 | * 235 | * @param bool $useIncludePath 236 | */ 237 | public function setUseIncludePath($useIncludePath) 238 | { 239 | $this->useIncludePath = $useIncludePath; 240 | } 241 | 242 | /** 243 | * Can be used to check if the autoloader uses the include path to check 244 | * for classes. 245 | * 246 | * @return bool 247 | */ 248 | public function getUseIncludePath() 249 | { 250 | return $this->useIncludePath; 251 | } 252 | 253 | /** 254 | * Turns off searching the prefix and fallback directories for classes 255 | * that have not been registered with the class map. 256 | * 257 | * @param bool $classMapAuthoritative 258 | */ 259 | public function setClassMapAuthoritative($classMapAuthoritative) 260 | { 261 | $this->classMapAuthoritative = $classMapAuthoritative; 262 | } 263 | 264 | /** 265 | * Should class lookup fail if not found in the current class map? 266 | * 267 | * @return bool 268 | */ 269 | public function isClassMapAuthoritative() 270 | { 271 | return $this->classMapAuthoritative; 272 | } 273 | 274 | /** 275 | * Registers this instance as an autoloader. 276 | * 277 | * @param bool $prepend Whether to prepend the autoloader or not 278 | */ 279 | public function register($prepend = false) 280 | { 281 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); 282 | } 283 | 284 | /** 285 | * Unregisters this instance as an autoloader. 286 | */ 287 | public function unregister() 288 | { 289 | spl_autoload_unregister(array($this, 'loadClass')); 290 | } 291 | 292 | /** 293 | * Loads the given class or interface. 294 | * 295 | * @param string $class The name of the class 296 | * @return bool|null True if loaded, null otherwise 297 | */ 298 | public function loadClass($class) 299 | { 300 | if ($file = $this->findFile($class)) { 301 | includeFile($file); 302 | 303 | return true; 304 | } 305 | } 306 | 307 | /** 308 | * Finds the path to the file where the class is defined. 309 | * 310 | * @param string $class The name of the class 311 | * 312 | * @return string|false The path if found, false otherwise 313 | */ 314 | public function findFile($class) 315 | { 316 | // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 317 | if ('\\' == $class[0]) { 318 | $class = substr($class, 1); 319 | } 320 | 321 | // class map lookup 322 | if (isset($this->classMap[$class])) { 323 | return $this->classMap[$class]; 324 | } 325 | if ($this->classMapAuthoritative) { 326 | return false; 327 | } 328 | 329 | $file = $this->findFileWithExtension($class, '.php'); 330 | 331 | // Search for Hack files if we are running on HHVM 332 | if ($file === null && defined('HHVM_VERSION')) { 333 | $file = $this->findFileWithExtension($class, '.hh'); 334 | } 335 | 336 | if ($file === null) { 337 | // Remember that this class does not exist. 338 | return $this->classMap[$class] = false; 339 | } 340 | 341 | return $file; 342 | } 343 | 344 | private function findFileWithExtension($class, $ext) 345 | { 346 | // PSR-4 lookup 347 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; 348 | 349 | $first = $class[0]; 350 | if (isset($this->prefixLengthsPsr4[$first])) { 351 | foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { 352 | if (0 === strpos($class, $prefix)) { 353 | foreach ($this->prefixDirsPsr4[$prefix] as $dir) { 354 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 355 | return $file; 356 | } 357 | } 358 | } 359 | } 360 | } 361 | 362 | // PSR-4 fallback dirs 363 | foreach ($this->fallbackDirsPsr4 as $dir) { 364 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 365 | return $file; 366 | } 367 | } 368 | 369 | // PSR-0 lookup 370 | if (false !== $pos = strrpos($class, '\\')) { 371 | // namespaced class name 372 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) 373 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); 374 | } else { 375 | // PEAR-like class name 376 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; 377 | } 378 | 379 | if (isset($this->prefixesPsr0[$first])) { 380 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { 381 | if (0 === strpos($class, $prefix)) { 382 | foreach ($dirs as $dir) { 383 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 384 | return $file; 385 | } 386 | } 387 | } 388 | } 389 | } 390 | 391 | // PSR-0 fallback dirs 392 | foreach ($this->fallbackDirsPsr0 as $dir) { 393 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 394 | return $file; 395 | } 396 | } 397 | 398 | // PSR-0 include paths. 399 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { 400 | return $file; 401 | } 402 | } 403 | } 404 | 405 | /** 406 | * Scope isolated include. 407 | * 408 | * Prevents access to $this/self from included files. 409 | */ 410 | function includeFile($file) 411 | { 412 | include $file; 413 | } 414 | -------------------------------------------------------------------------------- /vendor/davechild/textstatistics/src/DaveChild/TextStatistics/Syllables.php: -------------------------------------------------------------------------------- 1 | 4 15 | ,'abare' => 3 16 | ,'abed' => 2 17 | ,'abruzzese' => 4 18 | ,'abbruzzese' => 4 19 | ,'aborigine' => 5 20 | ,'acreage' => 3 21 | ,'adame' => 3 22 | ,'adieu' => 2 23 | ,'adobe' => 3 24 | ,'anemone' => 4 25 | ,'apache' => 3 26 | ,'aphrodite' => 4 27 | ,'apostrophe' => 4 28 | ,'ariadne' => 4 29 | ,'cafe' => 2 30 | ,'calliope' => 4 31 | ,'catastrophe' => 4 32 | ,'chile' => 2 33 | ,'chloe' => 2 34 | ,'circe' => 2 35 | ,'coyote' => 3 36 | ,'epitome' => 4 37 | ,'forever' => 3 38 | ,'gethsemane' => 4 39 | ,'guacamole' => 4 40 | ,'hyperbole' => 4 41 | ,'jesse' => 2 42 | ,'jukebox' => 2 43 | ,'karate' => 3 44 | ,'machete' => 3 45 | ,'maybe' => 2 46 | ,'people' => 2 47 | ,'recipe' => 3 48 | ,'sesame' => 3 49 | ,'shoreline' => 2 50 | ,'simile' => 3 51 | ,'syncope' => 3 52 | ,'tamale' => 3 53 | ,'yosemite' => 4 54 | ,'daphne' => 2 55 | ,'eurydice' => 4 56 | ,'euterpe' => 3 57 | ,'hermione' => 4 58 | ,'penelope' => 4 59 | ,'persephone' => 4 60 | ,'phoebe' => 2 61 | ,'zoe' => 2 62 | ); 63 | 64 | // These syllables would be counted as two but should be one 65 | static public $arrSubSyllables = array( 66 | 'cia(l|$)' // glacial, acacia 67 | ,'tia' 68 | ,'cius' 69 | ,'cious' 70 | ,'[^aeiou]giu' 71 | ,'[aeiouy][^aeiouy]ion' 72 | ,'iou' 73 | ,'sia$' 74 | ,'eous$' 75 | ,'[oa]gue$' 76 | ,'.[^aeiuoycgltdb]{2,}ed$' 77 | ,'.ely$' 78 | //,'[cg]h?ed?$' 79 | //,'rved?$' 80 | //,'[aeiouy][dt]es?$' 81 | //,'^[dr]e[aeiou][^aeiou]+$' // Sorts out deal, deign etc 82 | //,'[aeiouy]rse$' // Purse, hearse 83 | ,'^jua' 84 | //,'nne[ds]?$' // canadienne 85 | ,'uai' // acquainted 86 | ,'eau' // champeau 87 | //,'pagne[ds]?$' // champagne 88 | //,'[aeiouy][^aeiuoytdbcgrnzs]h?e[rsd]?$' 89 | // The following detects words ending with a soft e ending. Don't 90 | // mess with it unless you absolutely have to! The following 91 | // is a list of words you can use to test a new version of 92 | // this rule (add 'r', 's' and 'd' where possible to test 93 | // fully): 94 | // - absolve 95 | // - acquiesce 96 | // - audience 97 | // - ache 98 | // - acquire 99 | // - brunelle 100 | // - byrne 101 | // - canadienne 102 | // - coughed 103 | // - curved 104 | // - champagne 105 | // - designate 106 | // - force 107 | // - lace 108 | // - late 109 | // - lathe 110 | // - make 111 | // - relayed 112 | // - scrounge 113 | // - side 114 | // - sideline 115 | // - some 116 | // - wide 117 | // - taste 118 | ,'[aeiouy](b|c|ch|d|dg|f|g|gh|gn|k|l|ll|lv|m|mm|n|nc|ng|nn|p|r|rc|rn|rs|rv|s|sc|sk|sl|squ|ss|st|t|th|v|y|z)e$' 119 | // For soft e endings with a "d". Test words: 120 | // - crunched 121 | // - forced 122 | // - hated 123 | // - sided 124 | // - sidelined 125 | // - unexploded 126 | // - unexplored 127 | // - scrounged 128 | // - squelched 129 | // - forced 130 | ,'[aeiouy](b|c|ch|dg|f|g|gh|gn|k|l|lch|ll|lv|m|mm|n|nc|ng|nch|nn|p|r|rc|rn|rs|rv|s|sc|sk|sl|squ|ss|th|v|y|z)ed$' 131 | // For soft e endings with a "s". Test words: 132 | // - absences 133 | // - accomplices 134 | // - acknowledges 135 | // - advantages 136 | // - byrnes 137 | // - crunches 138 | // - forces 139 | // - scrounges 140 | // - squelches 141 | ,'[aeiouy](b|ch|d|f|gh|gn|k|l|lch|ll|lv|m|mm|n|nch|nn|p|r|rn|rs|rv|s|sc|sk|sl|squ|ss|st|t|th|v|y)es$' 142 | ,'^busi$' 143 | ); 144 | 145 | // These syllables would be counted as one but should be two 146 | static public $arrAddSyllables = array( 147 | '([^s]|^)ia' 148 | ,'riet' 149 | ,'dien' // audience 150 | ,'iu' 151 | ,'io' 152 | ,'eo($|[b-df-hj-np-tv-z])' 153 | ,'ii' 154 | ,'[ou]a$' 155 | ,'[aeiouym]bl$' 156 | ,'[aeiou]{3}' 157 | ,'[aeiou]y[aeiou]' 158 | ,'^mc' 159 | ,'ism$' 160 | ,'asm$' 161 | ,'thm$' 162 | ,'([^aeiouy])\1l$' 163 | ,'[^l]lien' 164 | ,'^coa[dglx].' 165 | ,'[^gq]ua[^auieo]' 166 | ,'dnt$' 167 | ,'uity$' 168 | ,'[^aeiouy]ie(r|st|t)$' 169 | ,'eings?$' 170 | ,'[aeiouy]sh?e[rsd]$' 171 | ,'iell' 172 | ,'dea$' 173 | ,'real' // real, cereal 174 | ,'[^aeiou]y[ae]' // bryan, byerley 175 | ,'gean$' // aegean 176 | ,'uen' // influence, affluence 177 | ); 178 | 179 | // Single syllable prefixes and suffixes 180 | static public $arrAffix = array( 181 | '`^un`' 182 | ,'`^fore`' 183 | ,'`^ware`' 184 | ,'`^none?`' 185 | ,'`^out`' 186 | ,'`^post`' 187 | ,'`^sub`' 188 | ,'`^pre`' 189 | ,'`^pro`' 190 | ,'`^dis`' 191 | ,'`^side`' 192 | ,'`ly$`' 193 | ,'`less$`' 194 | ,'`some$`' 195 | ,'`ful$`' 196 | ,'`ers?$`' 197 | ,'`ness$`' 198 | ,'`cians?$`' 199 | ,'`ments?$`' 200 | ,'`ettes?$`' 201 | ,'`villes?$`' 202 | ,'`ships?$`' 203 | ,'`sides?$`' 204 | ,'`ports?$`' 205 | ,'`shires?$`' 206 | ,'`tion(ed)?$`' 207 | ); 208 | 209 | // Double syllable prefixes and suffixes 210 | static public $arrDoubleAffix = array( 211 | '`^above`' 212 | ,'`^ant[ie]`' 213 | ,'`^counter`' 214 | ,'`^hyper`' 215 | ,'`^afore`' 216 | ,'`^agri`' 217 | ,'`^in[ft]ra`' 218 | ,'`^inter`' 219 | ,'`^over`' 220 | ,'`^semi`' 221 | ,'`^ultra`' 222 | ,'`^under`' 223 | ,'`^extra`' 224 | ,'`^dia`' 225 | ,'`^micro`' 226 | ,'`^mega`' 227 | ,'`^kilo`' 228 | ,'`^pico`' 229 | ,'`^nano`' 230 | ,'`^macro`' 231 | ,'`berry$`' 232 | ,'`woman$`' 233 | ,'`women$`' 234 | ); 235 | 236 | // Triple syllable prefixes and suffixes 237 | static public $arrTripleAffix = array( 238 | '`ology$`' 239 | ,'`ologist$`' 240 | ,'`onomy$`' 241 | ,'`onomist$`' 242 | ); 243 | 244 | /** 245 | * Returns the number of syllables in the word. 246 | * Based in part on Greg Fast's Perl module Lingua::EN::Syllables 247 | * @param string $strWord Word to be measured 248 | * @param string $strEncoding Encoding of text 249 | * @return int 250 | */ 251 | public static function syllableCount($strWord, $strEncoding = '') 252 | { 253 | 254 | // Trim whitespace 255 | $strWord = trim($strWord); 256 | 257 | // Check we have some letters 258 | if (Text::letterCount(trim($strWord), $strEncoding) == 0) { 259 | return 0; 260 | } 261 | 262 | // $debug is an array containing the basic syllable counting steps for 263 | // this word. 264 | $debug = array(); 265 | $debug['Counting syllables for'] = $strWord; 266 | 267 | // Should be no non-alpha characters and lower case 268 | $strWord = preg_replace('`[^A-Za-z]`', '', $strWord); 269 | $strWord = Text::lowerCase($strWord, $strEncoding); 270 | 271 | // Check for problem words 272 | if (isset(self::$arrProblemWords[$strWord])) { 273 | return self::$arrProblemWords[$strWord]; 274 | } 275 | // Try singular 276 | $singularWord = Pluralise::getSingular($strWord); 277 | if ($singularWord != $strWord) { 278 | if (isset(self::$arrProblemWords[$singularWord])) { 279 | return self::$arrProblemWords[$singularWord]; 280 | } 281 | } 282 | 283 | $debug['After cleaning, lcase'] = $strWord; 284 | 285 | // Remove prefixes and suffixes and count how many were taken 286 | $strWord = preg_replace(self::$arrAffix, '', $strWord, -1, $intAffixCount); 287 | $strWord = preg_replace(self::$arrDoubleAffix, '', $strWord, -1, $intDoubleAffixCount); 288 | $strWord = preg_replace(self::$arrTripleAffix, '', $strWord, -1, $intTripleAffixCount); 289 | 290 | if (($intAffixCount + $intDoubleAffixCount + $intTripleAffixCount) > 0) { 291 | $debug['After Prefix and Suffix Removal'] = $strWord; 292 | $debug['Prefix and suffix counts'] = $intAffixCount . ' * 1 syllable, ' . $intDoubleAffixCount . ' * 2 syllables, ' . $intTripleAffixCount . ' * 3 syllables'; 293 | } 294 | 295 | // Removed non-word characters from word 296 | $arrWordParts = preg_split('`[^aeiouy]+`', $strWord); 297 | $intWordPartCount = 0; 298 | foreach ($arrWordParts as $strWordPart) { 299 | if ($strWordPart <> '') { 300 | $debug['Counting (' . $intWordPartCount . ')'] = $strWordPart; 301 | $intWordPartCount++; 302 | } 303 | } 304 | 305 | // Some syllables do not follow normal rules - check for them 306 | // Thanks to Joe Kovar for correcting a bug in the following lines 307 | $intSyllableCount = $intWordPartCount + $intAffixCount + (2 * $intDoubleAffixCount) + (3 * $intTripleAffixCount); 308 | $debug['Syllables by Vowel Count'] = $intSyllableCount; 309 | 310 | foreach (self::$arrSubSyllables as $strSyllable) { 311 | $_intSyllableCount = $intSyllableCount; 312 | $intSyllableCount -= preg_match('`' . $strSyllable . '`', $strWord); 313 | if ($_intSyllableCount != $intSyllableCount) { 314 | $debug['Subtracting (' . $strSyllable . ')'] = $strSyllable; 315 | } 316 | } 317 | foreach (self::$arrAddSyllables as $strSyllable) { 318 | $_intSyllableCount = $intSyllableCount; 319 | $intSyllableCount += preg_match('`' . $strSyllable . '`', $strWord); 320 | if ($_intSyllableCount != $intSyllableCount) { 321 | $debug['Adding (' . $strSyllable . ')'] = $strSyllable; 322 | } 323 | } 324 | $intSyllableCount = ($intSyllableCount == 0) ? 1 : $intSyllableCount; 325 | 326 | $debug['Result'] = $intSyllableCount; 327 | 328 | return $intSyllableCount; 329 | } 330 | 331 | /** 332 | * Returns total syllable count for text. 333 | * @param string $strText Text to be measured 334 | * @param string $strEncoding Encoding of text 335 | * @return int 336 | */ 337 | public static function totalSyllables($strText, $strEncoding = '') 338 | { 339 | $intSyllableCount = 0; 340 | $arrWords = explode(' ', $strText); 341 | $intWordCount = count($arrWords); 342 | for ($i = 0; $i < $intWordCount; $i++) { 343 | $intSyllableCount += self::syllableCount($arrWords[$i], $strEncoding); 344 | } 345 | 346 | return $intSyllableCount; 347 | } 348 | 349 | /** 350 | * Returns average syllables per word for text. 351 | * @param string $strText Text to be measured 352 | * @param string $strEncoding Encoding of text 353 | * @return int|float 354 | */ 355 | public static function averageSyllablesPerWord($strText, $strEncoding = '') 356 | { 357 | $intSyllableCount = 0; 358 | $intWordCount = Text::wordCount($strText, $strEncoding); 359 | $arrWords = explode(' ', $strText); 360 | for ($i = 0; $i < $intWordCount; $i++) { 361 | $intSyllableCount += self::syllableCount($arrWords[$i], $strEncoding); 362 | } 363 | $averageSyllables = (Maths::bcCalc($intSyllableCount, '/', $intWordCount)); 364 | return $averageSyllables; 365 | } 366 | 367 | /** 368 | * Returns the number of words with more than three syllables 369 | * @param string $strText Text to be measured 370 | * @param bool $blnCountProperNouns Boolean - should proper nouns be included in words count 371 | * @param string $strEncoding Encoding of text 372 | * @return int 373 | */ 374 | public static function wordsWithThreeSyllables($strText, $blnCountProperNouns = true, $strEncoding = '') 375 | { 376 | $intLongWordCount = 0; 377 | $intWordCount = Text::wordCount($strText, $strEncoding); 378 | $arrWords = explode(' ', $strText); 379 | for ($i = 0; $i < $intWordCount; $i++) { 380 | if (Syllables::syllableCount($arrWords[$i], $strEncoding) > 2) { 381 | if ($blnCountProperNouns) { 382 | $intLongWordCount++; 383 | } else { 384 | $strFirstLetter = Text::substring($arrWords[$i], 0, 1, $strEncoding); 385 | if ($strFirstLetter !== Text::upperCase($strFirstLetter, $strEncoding)) { 386 | // First letter is lower case. Count it. 387 | $intLongWordCount++; 388 | } 389 | } 390 | } 391 | } 392 | 393 | return $intLongWordCount; 394 | } 395 | 396 | /** 397 | * Returns the percentage of words with more than three syllables 398 | * @param string $strText Text to be measured 399 | * @param bool $blnCountProperNouns Boolean - should proper nouns be included in words count 400 | * @return int|float 401 | */ 402 | public static function percentageWordsWithThreeSyllables($strText, $blnCountProperNouns = true, $strEncoding = '') 403 | { 404 | $intWordCount = Text::wordCount($strText, $strEncoding); 405 | $intLongWordCount = self::wordsWithThreeSyllables($strText, $blnCountProperNouns, $strEncoding); 406 | $intPercentage = Maths::bcCalc(Maths::bcCalc($intLongWordCount, '/', $intWordCount), '*', 100); 407 | 408 | return $intPercentage; 409 | } 410 | } 411 | --------------------------------------------------------------------------------