2017 © Pedro Peláez
 

library sourcemonkey

image

webspanner/sourcemonkey

  • Wednesday, August 1, 2018
  • by webspanner
  • Repository
  • 1 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 50 % Grown

The README.md

SourceMonkey

SourceMonkey is a package for working with source code, or text files on your local filesystem. SourceMonkey is useful for automated code generation and modification within your application., (*1)

Installation

To install with composer use the following command:, (*2)

composer install webspanner/sourcemonkey

Usage

Instantiating the class

Pass the fully qualified path to the file which you are editing into the constructor., (*3)

$sourceMonkey = new SourceMonkey('/tmp/my-file.php');

Methods

insertLineAfter()

To insert a string into a file after a given line number, moving all later text further down the page use the insertLineAfter() method, (*4)

$sourceMonkey->insertLineAfter('some string', 42);

write()

To write a string to a file, overwriting it's existing contents use the write() method., (*5)

$sourceMonkey->write('some string');

getLines()

To read the contents of a file into a 1-indexed array of strings, without line breaks use the getLines() method., (*6)

$sourceMonkey->getLines();

getPath()

Get the path of the SourceMonkey instance, (*7)

$sourceMonkey->getPath();

firstLineWithString()

Returns the line number of the first line which contains the given string, (*8)

$sourceMonkey->firstLineWithString($string);
{

deleteLine()

Delete the line at the given number, (*9)

$sourceMonkey->deleteLine($lineNumber);

replaceLine()

Replace the contents of the given line number with the given string, (*10)

$sourceMonkey->replaceLine($lineNumber, $string);

getProperty()

Get the PHP class property matching the given name from the class in the given source file and return it as a Property model object or null if it does not exist, (*11)

$sourceMonkey->getProperty($propertyName);

getClass()

Get the PHP class in the given file name, (*12)

$sourceMonkey->getClass()

The Versions

01/08 2018

dev-master

9999999-dev

  Sources   Download

The Requires

 

The Development Requires

01/08 2018

1.1.3

1.1.3.0

  Sources   Download

The Requires

 

The Development Requires

06/02 2018

1.1.2

1.1.2.0

  Sources   Download

The Requires

 

The Development Requires

06/02 2018

1.1.1

1.1.1.0

  Sources   Download

The Requires

 

The Development Requires

05/02 2018

1.1.0

1.1.0.0

  Sources   Download

The Requires

 

The Development Requires

01/07 2017

1.0.1

1.0.1.0

  Sources   Download

The Development Requires

08/06 2017

1.0.0

1.0.0.0

  Sources   Download

The Development Requires