is-class/README.md

22 lines
955 B
Markdown
Raw Permalink Normal View History

2016-10-08 19:00:31 -07:00
# is-class
2016-10-08 19:07:07 -07:00
[![Build Status](https://travis-ci.org/sikofitt/is-class.svg?branch=master)](https://travis-ci.org/sikofitt/is-class)
2016-10-08 19:00:31 -07:00
This program simply does one thing.
It creates a function ```is_class``` to go along with the many other 'is' functions.
`is_object` exists although it will return `true` if you execute `is_object(new \stdClass())` to me that seems like unexpected behavior. When somebody wants to find out if something is a class, they are usually not testing `\stdClass`.
`is_a` exists, but you need to know the name of the class in question. You simply can't call `is_a($class);`.
This function can be called as `is_class($class)`, which will return `true` for `interfaces` or `traits`.
The second way is `is_class($class, true)`, where true means strict, which will return `false` if anything is an `interface` or `trait`.
The function always returns false for `\stdClass`, you can use `is_object` for that.
## Tests
`phpunit`