From 550e061b7710b0423b523669f6c206e69f7da02f Mon Sep 17 00:00:00 2001 From: Kevin Hill Date: Tue, 14 Mar 2017 09:32:26 -0700 Subject: [PATCH] Including the parent class manually to allow non-composer usage. Updating CDN link to fontawesomecdn.com and version 4.7.0 --- src/FontAwesome.php | 51 +++++++++++++------------ src/FontAwesomeHtmlEntity.php | 70 +++++++++++++++++------------------ 2 files changed, 62 insertions(+), 59 deletions(-) diff --git a/src/FontAwesome.php b/src/FontAwesome.php index a424960..75aba32 100755 --- a/src/FontAwesome.php +++ b/src/FontAwesome.php @@ -2,9 +2,12 @@ namespace Khill\FontAwesome; +require __DIR__.'/FontAwesomeHtmlEntity.php'; + use InvalidArgumentException; use Khill\FontAwesome\FontAwesomeList; use Khill\FontAwesome\FontAwesomeStack; +use Khill\FontAwesome\FontAwesomeHtmlEntity; use Khill\FontAwesome\Support\Psr4Autoloader; use Khill\FontAwesome\Exceptions\BadLabelException; use Khill\FontAwesome\Exceptions\CollectionIconException; @@ -26,12 +29,12 @@ class FontAwesome extends FontAwesomeHtmlEntity /** * FontAwesomePHP version */ - const VERSION = '1.1.0'; + const VERSION = '1.1.3'; /** * FontAwesome Icon version */ - const FA_VERSION = '4.4.0'; + const FA_VERSION = '4.7.0'; /** * Html string template to build the icon @@ -58,9 +61,9 @@ class FontAwesome extends FontAwesomeHtmlEntity */ public static function css() { - return ''; + '/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous">'; } /** @@ -76,32 +79,13 @@ public function __construct($icon = null) $loader = new Psr4Autoloader; $loader->register(); - $loader->addNamespace(__NAMESPACE__, __DIR__); + $loader->addNamespace('Khill\FontAwesome', __DIR__); } if ($icon !== null) { $this->setIcon($icon); } } - - /** - * Checks if running in composer environment - * - * This will true if the folder 'composer' is within the path to FontAwesomePHP. - * - * @codeCoverageIgnore - * @access private - * @since 1.1.0 - * @return boolean - */ - private function usingComposer() - { - if (strpos(realpath(__FILE__), 'composer') !== false) { - return true; - } else { - return false; - } - } /** * Sets which icon to use @@ -290,4 +274,23 @@ protected function output() return sprintf(self::ICON_HTML, $classes, $attrs); } + + /** + * Checks if running in composer environment + * + * This will true if the folder 'composer' is within the path to FontAwesomePHP. + * + * @codeCoverageIgnore + * @access private + * @since 1.1.0 + * @return boolean + */ + private function usingComposer() + { + if (strpos(realpath(__FILE__), 'composer') !== false) { + return true; + } else { + return false; + } + } } diff --git a/src/FontAwesomeHtmlEntity.php b/src/FontAwesomeHtmlEntity.php index c9f7cd4..c3c3908 100755 --- a/src/FontAwesomeHtmlEntity.php +++ b/src/FontAwesomeHtmlEntity.php @@ -45,13 +45,13 @@ class FontAwesomeHtmlEntity */ protected $CLASS_MAP = array( 'lg' => 'fa-lg', - 'x2' => 'fa-2x', - 'x3' => 'fa-3x', - 'x4' => 'fa-4x', - 'x5' => 'fa-5x', - 'fixedWidth' => 'fa-fw', + 'x2' => 'fa-2x', // Alias + 'x3' => 'fa-3x', // Alias + 'x4' => 'fa-4x', // Alias + 'x5' => 'fa-5x', // Alias + 'fw' => 'fa-fw', 'fixed' => 'fa-fw', // Alias - 'fw' => 'fa-fw', // Alias + 'fixedWidth' => 'fa-fw', // Alias 'spin' => 'fa-spin', 's' => 'fa-spin', // Alias 'border' => 'fa-border', @@ -79,6 +79,35 @@ class FontAwesomeHtmlEntity 'r' => 'pull-right' // Alias ); + /** + * Magic method to assign transformation classes to the stack + * + * @param string $name Method called + * @param array $arguments + * @return self + * @throws InvalidTransformationClass + */ + public function __call($name, $arguments) + { + $this->classes[] = $this->classMapper($name); + + if (isset($arguments[0])) { + $this->icon = $arguments[0]; + } + + return $this; + } + + /** + * Outputs the FontAwesome object as an HTML string + * + * @return string HTML string of icon, stack, or list + */ + public function __toString() + { + return (string) $this->output(); + } + /** * Sets icon label * @@ -117,35 +146,6 @@ protected function classMapper($class) throw new InvalidTransformationClass($class); } - /** - * Magic method to assign transformation classes to the stack - * - * @param string $name Method called - * @param array $arguments - * @return self - * @throws InvalidTransformationClass - */ - public function __call($name, $arguments) - { - if (isset($arguments[0])) { - $this->icon = $arguments[0]; - } - - $this->classes[] = $this->classMapper($name); - - return $this; - } - - /** - * Outputs the FontAwesome object as an HTML string - * - * @return string HTML string of icon, stack, or list - */ - public function __toString() - { - return (string) $this->output(); - } - /** * Adds an attribute to the icon, useful for title or id *