PHPackages                             schlaus/tagline - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. schlaus/tagline

ActiveLibrary[Testing &amp; Quality](/categories/testing)

schlaus/tagline
===============

Tagline takes a tag and a file, and tells you if the tag is found in the file, and on which line.

v1.0.0(11y ago)017MITPHPPHP &gt;=5.3.0

Since May 22Pushed 11y ago1 watchersCompare

[ Source](https://github.com/schlaus/Tagline)[ Packagist](https://packagist.org/packages/schlaus/tagline)[ Docs](https://github.com/schlaus/tagline)[ RSS](/packages/schlaus-tagline/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Tagline
=======

[](#tagline)

[![Build Status](https://camo.githubusercontent.com/fe399cee9dd6161860b57d31c33857defaf20a2039a9aacd9187073f8db4e1ee/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7363686c6175732f5461676c696e652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/schlaus/Tagline)[![Coverage Status](https://camo.githubusercontent.com/2f0c0daf7a93c89205eeac99900c5bc6cd30d0e5e5e98724bbe3ce0f6990f242/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f7363686c6175732f5461676c696e652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/schlaus/Tagline?branch=master)[![Latest Version](https://camo.githubusercontent.com/d43cb58850a25686e20cc9d72a0ece96298e0bdc9e5f7b28dbd70ab89303fb7e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7363686c6175732f5461676c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schlaus/tagline)[![Total Downloads](https://camo.githubusercontent.com/dfb075611cf21c28bc5eed96b1ae627ab224f450e7d39e2f4ea9424ed2106af8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7363686c6175732f5461676c696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schlaus/tagline)[![Issues open](https://camo.githubusercontent.com/f04382969346f2c3a2229d2382b91768971053e1918a0feebe8dc70edc45a341/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f7363686c6175732f5461676c696e652e7376673f7374796c653d666c61742d737175617265)](https://github.com/schlaus/Tagline/issues)[![MIT license](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](http://schlaus.mit-license.org)

Tagline takes a tag and a file, and tells you if the tag is found in the file, and on which line. Basically it's a vertical `strpos()` that works on files.

Install
-------

[](#install)

Via Composer

```
$ composer require schlaus/tagline
```

Usage
-----

[](#usage)

### The basics

[](#the-basics)

```
use Schlaus\Tagline\Tagline;

$lineNr   = Tagline::findTag('FindMe!', 'somefile.php');
$nextLine = Tagline::findNext();
```

### API

[](#api)

The namespace for this package is `Schlaus\Tagline\Tagline`.

```
int Tagline::findTag(string $tag [, mixed $file = null [, int $offset = 0 [, string $interpretAs = null]]])

```

The main function this class provides. Takes in a tag, a target file, and optionally an offset, and looks for the first occurrence of that tag in the file. Returns false is the tag was not found, and throws an InvalidArgumentException if the file could not be read. Otherwise returns the line number the tag was first encountered on, as an integer.

Subsequent calls can be made without specifying a file, as the contents are cached on the first search. To bypass the cache simply specify the file again. This function always returns the first occurrence of the given tag. Use the `$offset` argument or the `Tagline::findNext()` method to find other occurrences.

#### Arguments

[](#arguments)

- `$tag` - A string to search for
- `$file` - The file to search in. Can be provided as one of the following:
    - A filename as a string
    - File contents as a string
    - File contents as an array
    - A stream resource
    - An instance of `SplFileObject`

A string is interpreted as a filename if it has no line breaks, even if such a file doesn't exist. This is to help you catch typos and logic errors. If you really want to look for a tag in a single line string, you can force the type interpretation with the fourth argument.

- `$offset` - Number of lines to skip from the top of the file
- `$interpretAs` - Forces input to be interpreted as a specific type. Can be one of the following:

    - 'string'
    - 'array'
    - 'filename'
    - 'stream'
    - 'fileobject'

```
int Tagline::findNext()

```

Returns the line number of the next occurrence of the tag that was last searched for, or false if no more occurrences are found.

```
array Tagline::anyToArray(mixed $source [, string $type = null])

```

A helper function for converting any supported source into a **zero-based** line-per-key array. The arguments are the as the second and the fourth argument for `Tagline::findTag()`.

There's comments aplenty in the source, and a rather exhaustive test suite which should help in figuring out how something works if it's not clear from this documentation.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see  for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4015d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3a43b3880ecbadd178a300fa7f0ff173dc56622c506c9f85822864f658df5d6?d=identicon)[schlaus](/maintainers/schlaus)

---

Tags

testingtaggingtagline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/schlaus-tagline/health.svg)

```
[![Health](https://phpackages.com/badges/schlaus-tagline/health.svg)](https://phpackages.com/packages/schlaus-tagline)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k892.4M1.5k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k201.2M4.2k](/packages/symfony-phpunit-bridge)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)

PHPackages © 2026

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