2017 © Pedro Peláez
 

library css_analyser

A PHP class to analyse a string of CSS to produce statistics.

image

gbuckingham89/css_analyser

A PHP class to analyse a string of CSS to produce statistics.

  • Thursday, July 24, 2014
  • by gbuckingham89
  • Repository
  • 3 Watchers
  • 4 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CSS Analyser

A PHP class to analyse a string of CSS to produce statistics. It is able to get the following information about a string of CSS:, (*1)

  • Number of rules
  • Number of selectors
  • Number of media queries
  • Number of property definitions
  • Size (in bytes)

The class assumes that your CSS is valid - always run your code through a CSS Lint tool first., (*2)

You can see a demo of the class in action at: www.cssanalyser.com., (*3)

Installation / Setup

The proper way

Use Composer - simply css_analyser to your composer.json file:, (*4)

{
    "require": {
        "gbuckingham89/css_analyser": "dev-master"
    }
}

The other way

Simply download and extract the ZIP into your project and include the class (css_analyser.php) using require() or include() in the most appropriate place for your project., (*5)

Usage

Input CSS and return all of the results as an array:, (*6)

$css_string = ".example-css { color: red; }";
$analyser = new \gbuckingham89\css_analyser();
$results = $analyser->process($css_string);

Or, if you only need one or two or the results, simply call the relevant m ethod:, (*7)

$css_string = ".example-css { color: red; }";
$analyser = new \gbuckingham89\css_analyser();
$analyser->process($css_string, false);
$number_of_rules = $analyser->get_rules_count();
$size = $analyser->get_size();

Contributing

Spotted any bugs? Got an idea for a new feature? Want to help improve? Open an issue and if you can supply the fix, submit a pull request., (*8)

Author

George Buckingham - www.georgebuckingham.com, (*9)

License

The MIT License (MIT), (*10)

Copyright (c) 2014 George Buckingham, (*11)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*12)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*13)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*14)

The Versions

24/07 2014

dev-master

9999999-dev http://github.com/gbuckingham89/css_analyser

A PHP class to analyse a string of CSS to produce statistics.

  Sources   Download

MIT

The Requires

  • php >=5.0.0

 

statistics css analyzer analyser