Skip to content

ScripturNum ScripturNum

GitHub Actions - update documentation edited this page Sep 19, 2024 · 3 revisions

ScripturNum\ScripturNum

The ScripturNum class, which represents a single continuous passage.

  • Class name: ScripturNum
  • Namespace: \ScripturNum

Constants

BOOK_MASK

const BOOK_MASK = 4278190080

START_MASK

const START_MASK = 16773120

END_MASK

const END_MASK = 4095

Properties

int

protected mixed int
  • Visibility: protected

book

protected mixed book
  • Visibility: protected

startCh

protected mixed startCh
  • Visibility: protected

startV

protected mixed startV
  • Visibility: protected

endCh

protected mixed endCh
  • Visibility: protected

endV

protected mixed endV
  • Visibility: protected

bibleClass

protected mixed bibleClass = \ScripturNum\Bible::class
  • Visibility: protected

stringSettings

protected mixed stringSettings = ['abbrev' => ['space' => '', 'cvsep' => '.', 'range' => '-', 'names' => 1, 'plurl' => false], 'long' => ['space' => ' ', 'cvsep' => ':', 'range' => '-', 'names' => 0, 'plurl' => true]]
  • Visibility: protected

Methods

__construct

mixed ScripturNum\ScripturNum::__construct(int|string intOrString)

ScripturNum constructor.

  • Visibility: public

Arguments

  • intOrString int|string - ScripturNum int or a human-readable string.

Returns

  • mixed

__get

int ScripturNum\ScripturNum::__get(mixed what)
  • Visibility: public

Arguments

  • what mixed

Returns

  • int -

setStringSettings

void ScripturNum\ScripturNum::setStringSettings(mixed key, array settings)

Update string settings.

  • Visibility: public
  • This method is static.

Arguments

  • key mixed* settings array

getInt

int ScripturNum\ScripturNum::getInt()

Get the ScripturNum integer.

  • Visibility: public

Returns

  • int - The ScripturNum integer

__toString

string ScripturNum\ScripturNum::__toString()

Generic toString. Uses the long form.

  • Visibility: public

Returns

  • string -

getAbbrev

string ScripturNum\ScripturNum::getAbbrev()

Get a human-readable abbreviation for the passage. By default, these are meant for usage in short links.

  • Visibility: public

Returns

  • string - An abbreviation

getLongString

string ScripturNum\ScripturNum::getLongString()

Get a human-readable name of the passage. By default, these are meant for humans to read.

  • Visibility: public

Returns

  • string - The name of the passage, as one might pronounce it.

toString

mixed ScripturNum\ScripturNum::toString(mixed options)

Get a string. Publically-accessible.

  • Visibility: public

Arguments

  • options mixed

Returns

  • mixed

getStringWithSettings

string ScripturNum\ScripturNum::getStringWithSettings(string|array options)

Returns a human-readable string with the settings defined in a given setting set.

  • Visibility: protected

Arguments

  • options string|array - The setting set to use, or an array of options.

Returns

  • string - The human-intelligible string.

isWholeChapters

bool ScripturNum\ScripturNum::isWholeChapters()

Returns true if the passage is an entire chapter.

  • Visibility: public

Returns

  • bool -

getWholeChapters

static ScripturNum\ScripturNum::getWholeChapters()

Returns a ScripturNum for the current range, expanded to the whole chapter.

  • Visibility: public

Returns

  • static -

getNextChapter

static ScripturNum\ScripturNum::getNextChapter()

Returns a ScripturNum for the chapter after the current highest chapter.

  • Visibility: public

Returns

  • static -

getPrevChapter

static ScripturNum\ScripturNum::getPrevChapter()

Returns a ScripturNum for the chapter prior to the current lowest chapter.

  • Visibility: public

Returns

  • static -

isWholeBook

bool ScripturNum\ScripturNum::isWholeBook()

Returns true if the passage is a whole book.

  • Visibility: public

Returns

  • bool -

isSingleVerse

bool ScripturNum\ScripturNum::isSingleVerse()

Returns true if the passage is just a single verse.

  • Visibility: public

Returns

  • bool -

bookHasSingleChapter

bool ScripturNum\ScripturNum::bookHasSingleChapter()

Returns true if the book only has one chapter (e.g. Jude)

  • Visibility: public

Returns

  • bool -

bookNameToBookNum

int ScripturNum\ScripturNum::bookNameToBookNum(mixed bookName)
  • Visibility: protected
  • This method is static.

Arguments

  • bookName mixed

Returns

  • int -

getBookNames

string[][] ScripturNum\ScripturNum::getBookNames()
  • Visibility: protected
  • This method is static.

Returns

  • string[][] -

getCommonTerms

string[] ScripturNum\ScripturNum::getCommonTerms()
  • Visibility: protected
  • This method is static.

Returns

  • string[] -

getConjunctions

string[] ScripturNum\ScripturNum::getConjunctions()
  • Visibility: protected
  • This method is static.

Returns

  • string[] -

pluralizeBookName

string ScripturNum\ScripturNum::pluralizeBookName(string bookNameSingular)
  • Visibility: protected
  • This method is static.

Arguments

  • bookNameSingular string

Returns

  • string -

newFromParsed

\ScripturNum\ScripturNum ScripturNum\ScripturNum::newFromParsed(string bookStr, ?int startCh, ?int startV, ?int endCh, ?int endV)
  • Visibility: public
  • This method is static.

Arguments

  • bookStr string* startCh ?int* startV ?int* endCh ?int* endV ?int

Returns

  • \ScripturNum\ScripturNum -

newFromInts

\ScripturNum\ScripturNum ScripturNum\ScripturNum::newFromInts(int book, int startCh, int|null startV, int|null endCh, int|null endV)
  • Visibility: public
  • This method is static.

Arguments

  • book int - The book of the Bible the range is within. 1-rel.
  • startCh int - The chapter of the start of the range. 1-rel.
  • startV int|null - The verse of the start of the range. 1-rel. Defaults to 1.
  • endCh int|null - The end chapter of the range. If null or not provided, assumed to be the same as the start chapter.
  • endV int|null - The end verse of the range. If null or not provided, assumed to be the end of the chapter.

Returns

  • \ScripturNum\ScripturNum - The ScripturNum object that represents this range of scripture.

stringToInt

int ScripturNum\ScripturNum::stringToInt(string string)

Takes a string that represents a single passage and returns it as an int.

  • Visibility: public
  • This method is static.

Arguments

  • string string - A human-readable scripture reference that should be converted to an int.

Returns

  • int - The int.

stringToInts

int[] ScripturNum\ScripturNum::stringToInts(string string, bool|array exceptions)

Takes a reference string and returns a plurality of ints for corresponding passages. This should only be passed values that are known to be references, not just any text. Use self::extractFromString for that.

  • Visibility: public
  • This method is static.

Arguments

  • string string - A human-readable scripture reference that should be converted to one or more ints. Allows for commas and semicolons.
  • exceptions bool|array - Pass an array to this parameter, and it will be populated with any exceptions that occur. By passing an array, this will not throw the exception, and by not throwing the exception, execution continues and you may be apprised of multiple errors that may exist.

Returns

  • int[] - The ints.

validateRefNums

void ScripturNum\ScripturNum::validateRefNums(int book, ?int startCh, ?int startV, ?int endCh, ?int endV)

Validate that reference numbers can be matched to verses that exist.

  • Visibility: protected
  • This method is static.

Arguments

  • book int* startCh ?int* startV ?int* endCh ?int* endV ?int

refNumsToInt

int ScripturNum\ScripturNum::refNumsToInt(int book, ?int startCh, ?int startV, ?int endCh, ?int endV)

Take reference indexes and convert them to the ScripturNum int. Assumes numbers are already validated by either safely existing or being validated against self::validateRefNums()

  • Visibility: protected
  • This method is static.

Arguments

  • book int* startCh ?int* startV ?int* endCh ?int* endV ?int

Returns

  • int -

refNumStringToRefNums

mixed ScripturNum\ScripturNum::refNumStringToRefNums(string string, mixed chapterStart, mixed verseStart, mixed chapterEnd, mixed verseEnd, bool useHints)

This function reads through a single ref string (e.g. 3:5-6:9) one character at a time to parse it into a known reference.

  • Visibility: protected
  • This method is static.

Arguments

  • string string - The string to parse.
  • chapterStart mixed* verseStart mixed* chapterEnd mixed* verseEnd mixed* useHints bool - If true, will consider the values provided to the chapter and verse parameters in parsing the string. Default false.

Returns

  • mixed

intToRefNums

mixed ScripturNum\ScripturNum::intToRefNums(int int, int book, int chapterStart, int verseStart, int chapterEnd, int verseEnd)

Converts a ScripturNum int into reference numbers.

  • Visibility: protected
  • This method is static.

Arguments

  • int int - The ScripturNum integer
  • book int - The book number
  • chapterStart int - The first Chapter
  • verseStart int - The first Verse
  • chapterEnd int - The last Chapter
  • verseEnd int - The last Verse

Returns

  • mixed

intToConcats

mixed ScripturNum\ScripturNum::intToConcats(int int, string|int concatStart, string|int concatEnd)

Convert a ScrupturNum int into a concatenated number. (Concatenated numbers are often used for text libraries.)

  • Visibility: public
  • This method is static.

Arguments

  • int int - The int representing the full passage
  • concatStart string|int - The concatenated "number" possibly larger than an int representing the start of the passage.
  • concatEnd string|int - The concatenated "number" possibly larger than an int representing the end of the passage.

Returns

  • mixed

bkIndexToSingleRef

mixed ScripturNum\ScripturNum::bkIndexToSingleRef(int book, int index, int chapter, int verse)

Parse a book index number into a chapter and verse.

  • Visibility: protected
  • This method is static.

Arguments

  • book int - Book number
  • index int - Verse Index Number
  • chapter int - Chapter
  • verse int - Verse

Returns

  • mixed

extractFromString

\ScripturNum\ScripturNumArray ScripturNum\ScripturNum::extractFromString(string string, bool excludeAllBookOnlyRefs, null exceptions)

Given a string with any kind of text content, this method will search for any human-readable scripture references and try to parse them into discrete passages. Returns a ScripturNumArray.

  • Visibility: public
  • This method is static.

Arguments

  • string string* excludeAllBookOnlyRefs bool* exceptions null

Returns

  • \ScripturNum\ScripturNumArray -

isWithinInt

bool ScripturNum\ScripturNum::isWithinInt(int largerPassage)

Test whether a given passage is within a given larger passage. Will also return true if they are the same.

  • Visibility: public

Arguments

  • largerPassage int

Returns

  • bool -

isWithin

bool ScripturNum\ScripturNum::isWithin(\ScripturNum\ScripturNum largerPassage)

Test whether a given passage is within a given larger passage. Will also return true if they are the same.

  • Visibility: public

Arguments

Returns

  • bool -

overlapsWithInt

bool ScripturNum\ScripturNum::overlapsWithInt(int otherPassage)

Test whether a given passage has any commonality with another passage.

  • Visibility: public

Arguments

  • otherPassage int

Returns

  • bool -

overlapsWith

bool ScripturNum\ScripturNum::overlapsWith(\ScripturNum\ScripturNum otherPassage)

Test whether a given passage has any commonality with another passage.

  • Visibility: public

Arguments

Returns

  • bool -

overlapsOrAdjacentInt

bool ScripturNum\ScripturNum::overlapsOrAdjacentInt(int otherPassage)

Test whether a given passage has any commonality with another passage, or is adjacent to it.

  • Visibility: public

Arguments

  • otherPassage int

Returns

  • bool -

overlapsOrAdjacent

bool ScripturNum\ScripturNum::overlapsOrAdjacent(\ScripturNum\ScripturNum otherPassage)

Test whether a given passage has any commonality with another passage, or is adjacent to it.

  • Visibility: public

Arguments

Returns

  • bool -

combineWithInt

int ScripturNum\ScripturNum::combineWithInt(int otherPassage)

Combines two adjacent or overlapping passages into one int.

  • Visibility: public

Arguments

  • otherPassage int

Returns

  • int -

combineWith

\ScripturNum\ScripturNum ScripturNum\ScripturNum::combineWith(\ScripturNum\ScripturNum otherPassage)

Combines two adjacent or overlapping passages into one ScripturNum.

  • Visibility: public

Arguments

Returns

  • \ScripturNum\ScripturNum -

containsInt

bool ScripturNum\ScripturNum::containsInt(int smallerPassage)

Test whether a given passage contains a given smaller passage. Will also return true if they are the same.

  • Visibility: public

Arguments

  • smallerPassage int

Returns

  • bool -

contains

bool ScripturNum\ScripturNum::contains(\ScripturNum\ScripturNum smallerPassage)

Test whether a given passage contains a given smaller passage. Will also return true if they are the same.

  • Visibility: public

Arguments

Returns

  • bool -

toSqlExclusive

string ScripturNum\ScripturNum::toSqlExclusive(string columnRef)

Generate a query statement that can be used to search an int column in generic SQL for a passage that is entirely contained within the given ScripturNum.

  • Visibility: public

Arguments

  • columnRef string - The name of the column or value to use in the query.

Returns

  • string -

toSqlInclusive

string ScripturNum\ScripturNum::toSqlInclusive(string columnRef)

Generate a query statement that can be used to search an int column in generic SQL for a passage that overlaps with the given ScripturNum.

  • Visibility: public

Arguments

  • columnRef string - The name of the column or value to use in the query.

Returns

  • string -
Clone this wiki locally