• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

estvoyage / value / 20 / 2
99%
master: 99%

Build:
DEFAULT BRANCH: master
Ran 05 Dec 2014 08:32PM UTC
Files 10
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

05 Dec 2014 08:20PM UTC coverage: 92.683% (-7.3%) from 100.0%
20.2

push

travis-ci

mageekguy
Use trait instead of class to define base class.

With class, it's not possible to override constructor visibility.
So, it's not possible to build a flyweight class (http://en.wikipedia.org/wiki/Flyweight_pattern) using a
base class because it's not possible to define its constructor as private, because it is public in the base class.
But with a trait, it's possible to override a method visibility at compile time, so it's possible to
create a flywieght class:

<?php

use estvoyage\value\world\integer;

class flyweight
{
   use integer {
      __construct as private;
      validate as isInteger;
   }

   function static build($value)
   {
      static $instances = [];

      if (! self::isInteger($value) || $value < 5 || $value > 10)
      {
	 throw new \domainException('Argument should be an integer ≥ 5 and ≤ 10');
      }

      if (! isset($instances[$value]))
      {
	 $instances[$value] = new self($value);
      }

      return $instances[$value];
   }
}

?>

38 of 41 relevant lines covered (92.68%)

0.93 hits per line

Source Files on job 20.2
  • Tree
  • List 0
  • Changed 5
  • Source Changed 5
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 20
  • Travis Job 20.2
  • 9f184de9 on github
  • Prev Job for on master (#19.3)
  • Next Job for on master (#21.3)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc