PHPackages                             gbuckingham89/css\_analyser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gbuckingham89/css\_analyser

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

gbuckingham89/css\_analyser
===========================

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

48PHP

Since Jul 24Pushed 11y ago1 watchersCompare

[ Source](https://github.com/gbuckingham89/css_analyser)[ Packagist](https://packagist.org/packages/gbuckingham89/css_analyser)[ RSS](/packages/gbuckingham89-css-analyser/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

CSS Analyser
============

[](#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:

- 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](http://csslint.net "CSS Lint") tool first.

**You can see a demo of the class in action at: [www.cssanalyser.com](http://www.cssanalyser.com "www.cssanalyser.com").**

Installation / Setup
--------------------

[](#installation--setup)

### The proper way

[](#the-proper-way)

Use [Composer](https://getcomposer.org "Composer") - simply css\_analyser to your composer.json file:

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

```

### The other way

[](#the-other-way)

Simply download and extract the [ZIP](https://github.com/gbuckingham89/css_analyser/archive/master.zip "Download ZIP") into your project and include the class (css\_analyser.php) using `require()` or `include()` in the most appropriate place for your project.

Usage
-----

[](#usage)

Input CSS and return all of the results as an array:

```
$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:

```
$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
------------

[](#contributing)

Spotted any bugs? Got an idea for a new feature? Want to help improve? Open an [issue](https://github.com/gbuckingham89/css_analyser/issues "Open an issue") and if you can supply the fix, submit a [pull request](https://github.com/gbuckingham89/css_analyser/pulls "Pull request").

Author
------

[](#author)

George Buckingham - [www.georgebuckingham.com](www.georgebuckingham.com "George Buckingham")

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2014 George Buckingham

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:

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

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.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/22ec38c802df71e6286b262e605a1b445f2657b8f834db0098d10a06c9ec1137?d=identicon)[gbuckingham89](/maintainers/gbuckingham89)

---

Top Contributors

[![gbuckingham89](https://avatars.githubusercontent.com/u/1455253?v=4)](https://github.com/gbuckingham89 "gbuckingham89 (2 commits)")

### Embed Badge

![Health badge](/badges/gbuckingham89-css-analyser/health.svg)

```
[![Health](https://phpackages.com/badges/gbuckingham89-css-analyser/health.svg)](https://phpackages.com/packages/gbuckingham89-css-analyser)
```

###  Alternatives

[ideea/language-detector

Detect languages by text

334.4k](/packages/ideea-language-detector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
