Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Nov 10, 2015
1 parent edd4622 commit 7646a37
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 1 deletion.
47 changes: 47 additions & 0 deletions README.md
Expand Up @@ -33,6 +33,48 @@ TermStore 1.x:
}
```

## Usage

All services are constructed via the `TermStoreFactory` class:

```php
use Queryr\TermStore\TermStoreFactory;
$factory = new TermStoreFactory(
$dbalConnection,
new TermStoreConfig( /* optional config */ )
);
```

`$dbalConnection` is a `Connection` object from [Doctrine DBAL](https://github.com/doctrine/dbal).

### Writing to the store

```php
$writer = $factory->newTermStoreWriter();

$writer->storeEntityFingerprint( $entityId, $fingerprint );
$writer->dropTermsForId( $entityId );
```

### Lookup up an EntityId based on terms

```php
$idLookup = $factory->newEntityIdLookup();

$idLookup->getItemIdByLabel( $languageCode, $labelText );
$idLookup->getItemIdByText( $languageCode, $termText );
$idLookup->getIdByLabel( $languageCode, $labelText );
// see the EntityIdLookup for all methods and their documentation
```

### Lookup label based on EntityId and language

```php
$labelLookup = $factory->newLabelLookup();
$labelLookup->getLabelByIdAndLanguage( $entityId, $languageCode );
// see the LabelLookup interface for documentation
```

## Running the tests

For tests only
Expand All @@ -49,6 +91,11 @@ For a full CI run

## Release notes

### Version 1.1.0 (2015-11-10)

* Added `newLabelLookup` to `TermStoreFactory`
* Improved documentation

### Version 1.0.0 (2015-11-03)

* Installation with Wikibase DataModel 4.x is now allowed
Expand Down
3 changes: 3 additions & 0 deletions src/EntityIdLookup.php
Expand Up @@ -3,6 +3,9 @@
namespace Queryr\TermStore;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
3 changes: 3 additions & 0 deletions src/LabelLookup.php
Expand Up @@ -5,6 +5,9 @@
use Wikibase\DataModel\Entity\EntityId;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
3 changes: 3 additions & 0 deletions src/TermStore.php
Expand Up @@ -8,6 +8,9 @@
use Wikibase\DataModel\Term\Fingerprint;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
3 changes: 3 additions & 0 deletions src/TermStoreConfig.php
Expand Up @@ -3,6 +3,9 @@
namespace Queryr\TermStore;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
3 changes: 3 additions & 0 deletions src/TermStoreException.php
Expand Up @@ -3,6 +3,9 @@
namespace Queryr\TermStore;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
14 changes: 13 additions & 1 deletion src/TermStoreFactory.php
Expand Up @@ -5,6 +5,9 @@
use Doctrine\DBAL\Connection;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down Expand Up @@ -43,7 +46,16 @@ public function newTermStoreWriter() {
}

/**
* Work with a more segregated interface if you can.
* @since 1.1
*
* @return LabelLookup
*/
public function newLabelLookup() {
return $this->newTermStore();
}

/**
* Work with a more segregated interface (TermStoreWriter, EntityIdLookup, LabelLookup) if you can.
*
* @return TermStore
*/
Expand Down
3 changes: 3 additions & 0 deletions src/TermStoreInstaller.php
Expand Up @@ -8,6 +8,9 @@
use Doctrine\DBAL\Types\Type;

/**
* Package public, except for the constructor
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down
3 changes: 3 additions & 0 deletions src/TermStoreWriter.php
Expand Up @@ -10,6 +10,9 @@
use Wikibase\DataModel\Term\Term;

/**
* Package public
* @since 0.2
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
Expand Down

0 comments on commit 7646a37

Please sign in to comment.