Overview

Namespaces

  • BSN
    • CryptUser

Classes

  • CryptJSONSource
  • CryptMySQLSource
  • CryptUser
  • SSLKey

Interfaces

  • CryptDataSource
  • Overview
  • Namespace
  • Class
  • Tree

Class CryptJSONSource

A JSON file based data source object for the CryptUsers.

BSN\CryptUser\CryptJSONSource implements BSN\CryptUser\CryptDataSource
Namespace: BSN\CryptUser
Copyright: Copyright 2013, Bryan Nielsen
Author: Bryan Nielsen, bnielsen1965@gmail.com
Located at Class/CryptJSONSource.php
Methods summary
public
# __construct( mixed $filename )

Constructor to set up the data source

Constructor to set up the data source

public string
# getSourceType( )

Get source type

Get source type

Returns

string
The data source type.

Implementation of

BSN\CryptUser\CryptDataSource::getSourceType()
public array|boolean
# getUserByName( string $username )

Get array of users that match a given name.

Get array of users that match a given name.

Parameters

$username
string
$username The username to search for in the data source.

Returns

array|boolean
An array of arrays containing user elements to create a user or FALSE if not found.

Implementation of

BSN\CryptUser\CryptDataSource::getUserByName()
public array
# getUsernames( )

Get a list of usernames

Get a list of usernames

Returns

array
An array of strings containing the usernames from the data source.

Implementation of

BSN\CryptUser\CryptDataSource::getUsernames()
public boolean
# saveUser( array $user )

Save the provided user details in the data source.

Save the provided user details in the data source.

Parameters

$user
array
$user An array of user elements to be saved.

Returns

boolean
Returns TRUE on success and FALSE on failure.

Implementation of

BSN\CryptUser\CryptDataSource::saveUser()
public boolean
# deleteUser( string $username )

Delete the specified user from the data source.

Delete the specified user from the data source.

Parameters

$username
string
$username The username of the user to delete.

Returns

boolean
Returns TRUE on success and FALSE on failure.

Implementation of

BSN\CryptUser\CryptDataSource::deleteUser()
private integer|boolean
# searchUsersForUser( array $users, mixed $username )

Search provided users array for the specified user.

Search provided users array for the specified user.

Parameters

$users
array
$users An array of user rows to search.
$username

Returns

integer|boolean
The array index for the user name or FALSE if not found.
public array
# readJSONFile( string $filename = NULL )

Read a JSON formatted file using the file locking mechanism and return as an associative array

Read a JSON formatted file using the file locking mechanism and return as an associative array

Parameters

$filename
string
$filename Optional filename of the JSON file to write. If not specified then the objects filename setting will be used.

Returns

array
| boolean An associative array or FALSE on failure.
public boolean
# writeJSONFile( array $data, string $filename = NULL )

Write a JSON formatted file using the file locking mechanism. The provided data array or object element will be used for the file contents.

Write a JSON formatted file using the file locking mechanism. The provided data array or object element will be used for the file contents.

Parameters

$data
array
| object $data An associative array or object to convert to JSON.
$filename
string
$filename Optional filename of the JSON file to write. If not specified then the objects filename setting will be used.

Returns

boolean
TRUE on success, FALSE on failure.
public boolean
# lockFile( BSN\CryptUser\CryptJSONSource::$filename $filename, createIfNotExist $createIfNotExist = TRUE )

Open and lock a file for both read and write operations.

Open and lock a file for both read and write operations.

Parameters

$filename
BSN\CryptUser\CryptJSONSource::$filename
Filename of file to open and lock.
$createIfNotExist
createIfNotExist
Optional boolean to specify if the file should be created if it does not exist.

Returns

boolean
Open status.

Throws

Exception
If cannot get lock on file for any reason.
public string
# lockedRead( BSN\CryptUser\CryptJSONSource::$filename $filename, createIfNotExist $createIfNotExist = TRUE )

Read file with lock.

Read file with lock.

Parameters

$filename
BSN\CryptUser\CryptJSONSource::$filename
Filename of file to read.
$createIfNotExist
createIfNotExist
Optional boolean to specify if the file should be created if it does not exist.

Returns

string
or boolean Returns file contents in a string or FALSE on failure.

Throws

Exception
If for any reason the file is not locked.
public boolean
# lockedWrite( string $filename, string $buffer, boolean $createIfNotExist = TRUE )

Write buffer to file with lock

Write buffer to file with lock

Parameters

$filename
string
$filename The filename to write.
$buffer
string
$buffer The buffer to write to the file.
$createIfNotExist
boolean
$createIfNotExist Optional, specifies if the file should be created if it does not already exist.

Returns

boolean
FALSE if write fails

Throws

Exception
If for any reason the file is not locked.
public
# __wakeup( )

The magic __wakeup() function is used to clean up the file pointers when the object is unserialized.

The magic __wakeup() function is used to clean up the file pointers when the object is unserialized.

Properties summary
private mixed $filename
#
private mixed $lockedFilePointer
#
private mixed $lockedFilename
#
cryptUser API documentation generated by ApiGen 2.8.0